Tag Archives: J2EE

Java Running Error: Could not find or load main class

[problem description]

User root is created in the/root/exercise folder HelloWorld.java The code is as follows:

Compile and run the file as follows:

Compile HelloWorld.java Generate bytecode file HelloWorld.class , running HelloWorld.class 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 class in the current directory.



Step 1: add the classpath system variable at the end of the profile file in/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: input source/etc/profile on the command line to make the system variables in/etc/profile effective and then run.

Note: you can modify system variables only if the current user is root. If you enter source/etc/profile on the command line, the system variable will only take effect temporarily. If you close terminal, the system variable will be restored to its original state. Because the system variable is loaded at system startup, the system variable will be loaded automatically only at the next system restart, so you don’t need to enter source/etc/profile again.

The results are as follows

Maven error: index downloads are disabled, search result may be incomplete

This article is reproduced from:

Solution to the problem of index downloads are disabled, search result may be incomplete when Maven imports dependent jar packages

Maven adds the solution of dependency query with no result
to solve the problem

[problem description]

When importing dependent jar packages with maven, an error is reported: index downloads are disabled, search result may be incomplete

Sometimes, even if the error is not reported, the query still does not respond.


1. Select Maven in preferences and select “download repository index updates on startup”.


2. Open the Maven warehouse.

3. Right click on the global warehouse and select “full index enabled”.

4. After selecting, Maven will download an index file of nearly 100 megabytes. After downloading, it will update the index. The process is relatively long, and it may get stuck. It is recommended not to do anything else during this period.

5. After that, we can search the content in select dependency.

In J2EE Tomcat webapps, there are only folder directories and no files

Problem description:
j2ee web debugging process I found that no matter how I modified it did not change, and then I clean it, but after this program can not run, 404 can not find resources.

Reason analysis:
checked the path of the release project
controller in classes these folders are all directories, no files, after searching baidu, it should be a reference project lack of jar package, leading to the project build failure, but the empty directory was built, leading to this problem.

once I know what the problem is, I remove the jar from the path and add it again, and the project runs.

Problems encountered after Maven installation or upgrade: could not find or load main class org.codehaus.plexus .class…..

After the M2_HOME environment variable is changed, mVN-V is executed on the terminal and the following error occurs:
Exception in thread “main” java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org. Codehaus. Breadth. Classworlds. The launcher. The launcher. The Program will exit.
If you are a Linux system, you may be in the/etc/profile, ~ /. Following/~/bashrc file configured in the environment variable M2_HOME, when M2_HOME value change, even if you execute the source/etc/profile operation, also can appear as wrong, then you will need to open a terminal or log back in to, if you are a Windows system, to open a CMD window, generally is ok, So the root cause of the appeal error is that mVN-V was executed on the same terminal when switching between two versions of Maven without opening a new terminal or logging in again.