search
HomeJavaJavaBaseRunning the java class file from the command line prompts that the main class cannot be found or cannot be loaded.

Running the java class file from the command line prompts that the main class cannot be found or cannot be loaded.

问题如下

TestOne.java

package moon.star;
public class TestOne {
	public void fTestOne() {
  		System.out.println("I an a method In TestOne class");	
	}
}

相关学习视频推荐:java视频教程

TestTwo.java

package moon.star;
public class TestTwo {
	public void fTestTwo() {
  		System.out.println("I an a method In TestTwo class");
 	}
}

运行的代码:

import moon.star.*;
public class Use {	
	public static void main(String args[]) {
  		TestOne a = new TestOne();
  		a.fTestOne();
  		TestTwo b = new TestTwo();
  		b.fTestTwo();
 	}
}

输入 javac Use.java编译没有问题,输入java Use运行时却出错!

Running the java class file from the command line prompts that the main class cannot be found or cannot be loaded.

问题解决

命令行输入set classpath=C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\Jerry.jar;.;E:\1000

来指明我的moon.star包的位置,位置是E:\1000,即包名为moon.star的类的字节码存放在E:\1000\moon\star目录中。用户可以更新classpath的设置。

C:\Users\前世药师\Desktop>set classpath=C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\Jerry.jar;.;E:\1000

问题解决,成功运行结果图如下:

Running the java class file from the command line prompts that the main class cannot be found or cannot be loaded.

想了解更多相关问题,可以访问:java语言入门

The above is the detailed content of Running the java class file from the command line prompts that the main class cannot be found or cannot be loaded.. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software