I am trying to run a Java application, but getting this error:
java.lang.ClassNotFoundException:
After the colon comes the location of the cla
If you are using maven try to maven update all projects and force for snapshots. It will clean as well and rebuilt all classpath.. It solved my problem..
This can happen on Windows after a java update where the old version of the java SDK is missing and a new one is present. I would check if your IDE is using the installed java SDK version (IntelliJ: CTRL + SHIFT + ALT + S)
Add the full path of jar file to the CLASSPATH.
In linux use: export CLASSPATH=".:/full/path/to/file.jar:$CLASSPATH"
. Other way worked (without editing the CLASSPATH) was unzipping the jar in the current project folder.
Ways didn't work for me:
1) Using -cp
option with full path of jar file.
2) Using -cp
with only the name of jar when located in the current folder
3) Copying the jar to the current project folder
4) Copying the jar to standard location of java jars (/usr/share/java)
This solution is reported for class com.mysql.jdbc.Driver in mysql-connector-java.5-*.jar, working on linux with OpenJDK version 1.7
Use ';' as the separator. If your environment variables are set correctly, you should see your settings. If your PATH and CLASSPATH is correct, windows should recognize those commands. You do NOT need to restart your computer when installing Java.
To add the location of a class to your classpath via command line simply add -cp
or -classpath
and the location of the class while running it. I.E.
java -cp "c:/location/of/file" YourProgram
Or if you're running an IDE such as eclipse you can right click on the project -> build path -> configure build path
and add the external JAR containing your class to the build path then it should work fine.
In my case the class thrown as class not found exception has properties related to ssl certificates. Close the eclipse and open with as “Run as Administrator” then issue got resolved. As eclipse have issue related permission it will throw such kind of exception.