Compile helloworld.java to generate the bytecode file helloworld.class, and run helloworld.class with error: could not find or load main class
[cause analysis]
The current directory is the directory where the. Class file is located. To run the. Class bytecode file, you need to add the current directory to the system variable classpath to find the Java classes in the current directory.
The classpath path is entered incorrectly. You need to enter the current path and add.:
[solution]
Step 1: add.:,. In front of the classpath system variable at the end of the profile file under/etc to represent the current path
The classpath in the original/etc/profile file is:
CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
The added classpath is: classpath =.: $Java_HOME/jre/lib/ext:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
Step 2: on the command line, enter source/etc/profile to make the system variables in/etc/profile take effect and run.
Similar Posts:
- JAVA Command Error: A JNI error has occurred, please check your installation and try again [Solved]
- [olved] flume Install Error: Could not find or load main class org.apache.flume.tools.GetJavaProperty
- Mac ADB prompts command not found
- The CATALINA_HOME environment variable is not defined correctly
- [Solved] NB: JAVA_HOME should point to a JDK not a JRE
- [Solved] JPype Error: FileNotFoundError: [Errno 2] No such file or directory: ‘/usr/lib/jvm’
- SDK manager cannot open the solution (Android)
- After installing node on MAC, enter node – V to prompt node command not found
- Jenkins – mvn: command not found
- [Solved] Fel:Cannot find the system Java compiler. Check that your class path includes tools.jar