How do I resolve ClassNotFoundException?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







82















I am trying to run a Java application, but getting this error:



java.lang.ClassNotFoundException:



After the colon comes the location of the class that is missing. However, I know that that location does not exist since the class is located elsewhere. How can I update the path of that class? Does it have something to do with the class path?










share|improve this question




















  • 1





    You must add the jar which has the missing class to the classptah

    – Crom
    Jul 1 '13 at 16:00











  • if your class has a package then go to the folder containing the class. e.g if package is package test.abc, then go to folder before test and then do java -cp . test.abc.CLASSNAME (without .class). If there's no package then go to folder containing class and say java -cp . CLASSNAME

    – Optional
    Jul 1 '13 at 16:05













  • Either a class was not deployed to your runtime (for example missing jar), or the class is not visible in a given class loader, check this this tool that helps troubleshooting these problems: jhades.org

    – Angular University
    Dec 6 '13 at 12:05











  • I also run into this sometimes. This exception clearly violates the rule of stating all necessary context in an exception message. It should mention where it tried to look for the thing, what is on your classpath. Please make better exception messages. Don't make us hunt for information which could help solve the problem.

    – masterxilo
    Nov 25 '18 at 14:12


















82















I am trying to run a Java application, but getting this error:



java.lang.ClassNotFoundException:



After the colon comes the location of the class that is missing. However, I know that that location does not exist since the class is located elsewhere. How can I update the path of that class? Does it have something to do with the class path?










share|improve this question




















  • 1





    You must add the jar which has the missing class to the classptah

    – Crom
    Jul 1 '13 at 16:00











  • if your class has a package then go to the folder containing the class. e.g if package is package test.abc, then go to folder before test and then do java -cp . test.abc.CLASSNAME (without .class). If there's no package then go to folder containing class and say java -cp . CLASSNAME

    – Optional
    Jul 1 '13 at 16:05













  • Either a class was not deployed to your runtime (for example missing jar), or the class is not visible in a given class loader, check this this tool that helps troubleshooting these problems: jhades.org

    – Angular University
    Dec 6 '13 at 12:05











  • I also run into this sometimes. This exception clearly violates the rule of stating all necessary context in an exception message. It should mention where it tried to look for the thing, what is on your classpath. Please make better exception messages. Don't make us hunt for information which could help solve the problem.

    – masterxilo
    Nov 25 '18 at 14:12














82












82








82


18






I am trying to run a Java application, but getting this error:



java.lang.ClassNotFoundException:



After the colon comes the location of the class that is missing. However, I know that that location does not exist since the class is located elsewhere. How can I update the path of that class? Does it have something to do with the class path?










share|improve this question
















I am trying to run a Java application, but getting this error:



java.lang.ClassNotFoundException:



After the colon comes the location of the class that is missing. However, I know that that location does not exist since the class is located elsewhere. How can I update the path of that class? Does it have something to do with the class path?







java class classpath classnotfoundexception






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 5 '17 at 14:20









vaxquis

7,80853958




7,80853958










asked Jul 1 '13 at 15:58









user2426316user2426316

2,406134169




2,406134169








  • 1





    You must add the jar which has the missing class to the classptah

    – Crom
    Jul 1 '13 at 16:00











  • if your class has a package then go to the folder containing the class. e.g if package is package test.abc, then go to folder before test and then do java -cp . test.abc.CLASSNAME (without .class). If there's no package then go to folder containing class and say java -cp . CLASSNAME

    – Optional
    Jul 1 '13 at 16:05













  • Either a class was not deployed to your runtime (for example missing jar), or the class is not visible in a given class loader, check this this tool that helps troubleshooting these problems: jhades.org

    – Angular University
    Dec 6 '13 at 12:05











  • I also run into this sometimes. This exception clearly violates the rule of stating all necessary context in an exception message. It should mention where it tried to look for the thing, what is on your classpath. Please make better exception messages. Don't make us hunt for information which could help solve the problem.

    – masterxilo
    Nov 25 '18 at 14:12














  • 1





    You must add the jar which has the missing class to the classptah

    – Crom
    Jul 1 '13 at 16:00











  • if your class has a package then go to the folder containing the class. e.g if package is package test.abc, then go to folder before test and then do java -cp . test.abc.CLASSNAME (without .class). If there's no package then go to folder containing class and say java -cp . CLASSNAME

    – Optional
    Jul 1 '13 at 16:05













  • Either a class was not deployed to your runtime (for example missing jar), or the class is not visible in a given class loader, check this this tool that helps troubleshooting these problems: jhades.org

    – Angular University
    Dec 6 '13 at 12:05











  • I also run into this sometimes. This exception clearly violates the rule of stating all necessary context in an exception message. It should mention where it tried to look for the thing, what is on your classpath. Please make better exception messages. Don't make us hunt for information which could help solve the problem.

    – masterxilo
    Nov 25 '18 at 14:12








1




1





You must add the jar which has the missing class to the classptah

– Crom
Jul 1 '13 at 16:00





You must add the jar which has the missing class to the classptah

– Crom
Jul 1 '13 at 16:00













if your class has a package then go to the folder containing the class. e.g if package is package test.abc, then go to folder before test and then do java -cp . test.abc.CLASSNAME (without .class). If there's no package then go to folder containing class and say java -cp . CLASSNAME

– Optional
Jul 1 '13 at 16:05







if your class has a package then go to the folder containing the class. e.g if package is package test.abc, then go to folder before test and then do java -cp . test.abc.CLASSNAME (without .class). If there's no package then go to folder containing class and say java -cp . CLASSNAME

– Optional
Jul 1 '13 at 16:05















Either a class was not deployed to your runtime (for example missing jar), or the class is not visible in a given class loader, check this this tool that helps troubleshooting these problems: jhades.org

– Angular University
Dec 6 '13 at 12:05





Either a class was not deployed to your runtime (for example missing jar), or the class is not visible in a given class loader, check this this tool that helps troubleshooting these problems: jhades.org

– Angular University
Dec 6 '13 at 12:05













I also run into this sometimes. This exception clearly violates the rule of stating all necessary context in an exception message. It should mention where it tried to look for the thing, what is on your classpath. Please make better exception messages. Don't make us hunt for information which could help solve the problem.

– masterxilo
Nov 25 '18 at 14:12





I also run into this sometimes. This exception clearly violates the rule of stating all necessary context in an exception message. It should mention where it tried to look for the thing, what is on your classpath. Please make better exception messages. Don't make us hunt for information which could help solve the problem.

– masterxilo
Nov 25 '18 at 14:12












18 Answers
18






active

oldest

votes


















27














Your classpath is broken (which is a very common problem in the Java world).



Depending on how you start your application, you need to revise the argument to -cp, your Class-Path entry in MANIFEST.MF or your disk layout.






share|improve this answer



















  • 24





    Can you please be more eclipse specific? What do I have to do?

    – user2426316
    Jul 1 '13 at 16:03






  • 19





    Your question does not contain enough information to provide a more specfiic answer. Consider adding that.

    – Thorbjørn Ravn Andersen
    Jul 1 '13 at 16:06











  • Dependency resolution/version mismatches is a very common problem in basically all programming environments. We could say that all any program ever does is resolve such definitions... the question is always what/where is the definition and which version did you mean?

    – masterxilo
    Nov 23 '18 at 22:44











  • @masterxilo What point are you trying to make?

    – Thorbjørn Ravn Andersen
    Nov 24 '18 at 1:13






  • 2





    I am just emphasizing that besides the Java world all of software has a fight with ensuring that correct versions of dependencies are found. I can mention dll-hell, package managers, version managers, spring boot bill of materials and docker containers as examples of this problem and possible solutions. The larger the fraction of foreign code becones the larger the problem gets.

    – masterxilo
    Nov 25 '18 at 14:08



















38














A classpath is a list of locations to load classes from.



These 'locations' can either be directories, or jar files.



For directories, the JVM will follow an expected pattern for loading a class. If I have the directory C:/myproject/classes in my classpath, and I attempt to load a class com.mycompany.Foo, it will look under the classes directory for a directory called com, then under that a directory called mycompany, and finally it will look for a file called Foo.class in that directory.



In the second instance, for jar files, it will search the jar file for that class. A jar file is in reality just a zipped collection of directories like the above. If you unzip a jar file, you'll get a bunch of directories and class files following the pattern above.



So the JVM traverses a classpath from start to finish looking for the definition of the class when it attempts to load the class definition. For example, in the classpath :



C:/myproject/classes;C:/myproject/lib/stuff.jar;C:/myproject/lib/otherstuff.jar



The JVM will attempt to look in the directory classes first, then in stuff.jar and finally in otherstuff.jar.



When you get a ClassNotFoundException, it means the JVM has traversed the entire classpath and not found the class you've attempted to reference. The solution, as so often in the Java world, is to check your classpath.



You define a classpath on the command line by saying java -cp and then your classpath. In an IDE such as Eclipse, you'll have a menu option to specify your classpath.






share|improve this answer
























  • But how do I actually find what my classpath is

    – Philip Rego
    2 days ago



















10














This is the best solution I found so far.



Suppose we have a package called org.mypackage containing the classes:




  • HelloWorld (main class)

  • SupportClass

  • UtilClass


and the files defining this package are stored physically under the directory D:myprogram (on Windows) or /home/user/myprogram (on Linux).



The file structure will look like this:
enter image description here



When we invoke Java, we specify the name of the application to run: org.mypackage.HelloWorld. However we must also tell Java where to look for the files and directories defining our package. So to launch the program, we have to use the following command:
enter image description here




NOTE: You have to execute the above java command no matter what your current location is. But this is not the case for javac. For
compiling you can even directly go into the directory where you have
your .java files and directly execute javac ClassName.java.







share|improve this answer

































    6














    If you know the path of the class or the jar containing the class then add it to your classpath while running it. You can use the classpath as mentioned here:



    on Windows



    java -classpath .;yourjar.jar YourMainClass


    on UNIX/Linux



    java -classpath .:yourjar.jar YourMainClass





    share|improve this answer

































      4














      Try these if you use maven. I use maven for my project and when I do mvn clean install and try to run a program it throws the exception. So, I clean the project and run it again and it works for me.



      I use eclipse IDE.



      For Class Not Found Exception when running Junit test, try running mvn clean test once. It will compile all the test classes.






      share|improve this answer


























      • what directory were you in when you ran "mvn clean test"? is it in the same directory as the POM?

        – TacoB0t
        Mar 27 '18 at 16:19






      • 1





        Yes. Ran it from the directory where pom file is present.

        – Arun
        Mar 27 '18 at 18:26



















      3














      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.






      share|improve this answer

































        3














        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.






        share|improve this answer



















        • 5





          That is on windows (semicolon) , on unix/linux it is ':' (colon)

          – Joeblade
          Jan 19 '15 at 8:38



















        3














        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 -cpwith 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






        share|improve this answer


























        • Only unzipping the JAR worked for me, none of the other solutions did

          – OverCoder
          Jun 5 '16 at 23:05



















        2














        Go up to the top and remove the import statement if there is one, and re import the class. But if that isn't the case do a clean then build. Are you using Netbeans or Eclipse?






        share|improve this answer































          2














          I ran into this as well and tried all of the other solutions. I did not have the .class file in my HTML folder, I only had the .java file. Once I added the .class file the program worked fine.






          share|improve this answer































            2















            1. It could happen if your classpath is not correct


            2. Let us posit a serializable class and deserializable class under same projectname. You run the serializable class, creating a serializable object in specific folder. Now you need the desearialized data. In the meantime, if you change the name of the project it will not work. You have to run the serializable class first and then deserialize the file.







            share|improve this answer

































              2














              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..






              share|improve this answer































                2














                I just did



                1.Invalidate caches and restart



                2.Rebuilt my project which solved the problem






                share|improve this answer































                  1














                  I was trying to run .jar from C# code using Process class. The java code ran successfully from eclipse but it doesn't from C# visual studio and even clicking directly on the jar file, it always stopped with ClassNotFoundException: exception. Solution for my, was export the java program as "Runnable JAR file" instead of "JAR File". Hope it can help someone.






                  share|improve this answer































                    1














                    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)






                    share|improve this answer































                      0














                      If you have added multiple (Third-Party)**libraries and Extends **Application class



                      Then it might occur.



                      For that, you have to set multiDexEnabled true and replace your extended Application class with MultiDexApplication.



                      It will be solved.






                      share|improve this answer































                        0














                        Basic Generic Question - Simplest Generic Answer ;)



                        Given the information I will make the assumption that you might be trying a basic approach to coding, building/compiling and running a simple console app like "Hello World", using some simple text editor and some Command Shell.



                        This error occurs in the fallowing scenario:



                        ..SomePath>javac HelloWorld.java
                        ..SomePath>java HelloWorld.class


                        In other words, use:



                        ..SomePath>java HelloWorld


                        P.S. The adding the file extension .class produces the same mistake.
                        Also be sure to have the Java's (JDK/JRE) bin folder in the operating system's Environment Variables's PATH.(Lookup for more details other posts on this)
                        P.P.S Was I correct in my assumption/s?






                        share|improve this answer































                          -4














                          Put all the code in try block then catch exception in a catch block



                          try
                          {
                          // code
                          }
                          catch(ClassNotFoundException e1)
                          {
                          e1.getmessage();
                          }





                          share|improve this answer





















                          • 2





                            This does not resolve the exception. This hides the exception. Furthermore, "e1.getmessage()" is a) the wrong capitalisation of getMessage() and b) not going to do very much as it returns a string with a message and you're not printing it or logging it or anything!

                            – IBBoard
                            Aug 30 '16 at 12:15










                          protected by Community Jul 9 '16 at 17:57



                          Thank you for your interest in this question.
                          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                          Would you like to answer one of these unanswered questions instead?














                          18 Answers
                          18






                          active

                          oldest

                          votes








                          18 Answers
                          18






                          active

                          oldest

                          votes









                          active

                          oldest

                          votes






                          active

                          oldest

                          votes









                          27














                          Your classpath is broken (which is a very common problem in the Java world).



                          Depending on how you start your application, you need to revise the argument to -cp, your Class-Path entry in MANIFEST.MF or your disk layout.






                          share|improve this answer



















                          • 24





                            Can you please be more eclipse specific? What do I have to do?

                            – user2426316
                            Jul 1 '13 at 16:03






                          • 19





                            Your question does not contain enough information to provide a more specfiic answer. Consider adding that.

                            – Thorbjørn Ravn Andersen
                            Jul 1 '13 at 16:06











                          • Dependency resolution/version mismatches is a very common problem in basically all programming environments. We could say that all any program ever does is resolve such definitions... the question is always what/where is the definition and which version did you mean?

                            – masterxilo
                            Nov 23 '18 at 22:44











                          • @masterxilo What point are you trying to make?

                            – Thorbjørn Ravn Andersen
                            Nov 24 '18 at 1:13






                          • 2





                            I am just emphasizing that besides the Java world all of software has a fight with ensuring that correct versions of dependencies are found. I can mention dll-hell, package managers, version managers, spring boot bill of materials and docker containers as examples of this problem and possible solutions. The larger the fraction of foreign code becones the larger the problem gets.

                            – masterxilo
                            Nov 25 '18 at 14:08
















                          27














                          Your classpath is broken (which is a very common problem in the Java world).



                          Depending on how you start your application, you need to revise the argument to -cp, your Class-Path entry in MANIFEST.MF or your disk layout.






                          share|improve this answer



















                          • 24





                            Can you please be more eclipse specific? What do I have to do?

                            – user2426316
                            Jul 1 '13 at 16:03






                          • 19





                            Your question does not contain enough information to provide a more specfiic answer. Consider adding that.

                            – Thorbjørn Ravn Andersen
                            Jul 1 '13 at 16:06











                          • Dependency resolution/version mismatches is a very common problem in basically all programming environments. We could say that all any program ever does is resolve such definitions... the question is always what/where is the definition and which version did you mean?

                            – masterxilo
                            Nov 23 '18 at 22:44











                          • @masterxilo What point are you trying to make?

                            – Thorbjørn Ravn Andersen
                            Nov 24 '18 at 1:13






                          • 2





                            I am just emphasizing that besides the Java world all of software has a fight with ensuring that correct versions of dependencies are found. I can mention dll-hell, package managers, version managers, spring boot bill of materials and docker containers as examples of this problem and possible solutions. The larger the fraction of foreign code becones the larger the problem gets.

                            – masterxilo
                            Nov 25 '18 at 14:08














                          27












                          27








                          27







                          Your classpath is broken (which is a very common problem in the Java world).



                          Depending on how you start your application, you need to revise the argument to -cp, your Class-Path entry in MANIFEST.MF or your disk layout.






                          share|improve this answer













                          Your classpath is broken (which is a very common problem in the Java world).



                          Depending on how you start your application, you need to revise the argument to -cp, your Class-Path entry in MANIFEST.MF or your disk layout.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jul 1 '13 at 16:02









                          Thorbjørn Ravn AndersenThorbjørn Ravn Andersen

                          58.3k25151291




                          58.3k25151291








                          • 24





                            Can you please be more eclipse specific? What do I have to do?

                            – user2426316
                            Jul 1 '13 at 16:03






                          • 19





                            Your question does not contain enough information to provide a more specfiic answer. Consider adding that.

                            – Thorbjørn Ravn Andersen
                            Jul 1 '13 at 16:06











                          • Dependency resolution/version mismatches is a very common problem in basically all programming environments. We could say that all any program ever does is resolve such definitions... the question is always what/where is the definition and which version did you mean?

                            – masterxilo
                            Nov 23 '18 at 22:44











                          • @masterxilo What point are you trying to make?

                            – Thorbjørn Ravn Andersen
                            Nov 24 '18 at 1:13






                          • 2





                            I am just emphasizing that besides the Java world all of software has a fight with ensuring that correct versions of dependencies are found. I can mention dll-hell, package managers, version managers, spring boot bill of materials and docker containers as examples of this problem and possible solutions. The larger the fraction of foreign code becones the larger the problem gets.

                            – masterxilo
                            Nov 25 '18 at 14:08














                          • 24





                            Can you please be more eclipse specific? What do I have to do?

                            – user2426316
                            Jul 1 '13 at 16:03






                          • 19





                            Your question does not contain enough information to provide a more specfiic answer. Consider adding that.

                            – Thorbjørn Ravn Andersen
                            Jul 1 '13 at 16:06











                          • Dependency resolution/version mismatches is a very common problem in basically all programming environments. We could say that all any program ever does is resolve such definitions... the question is always what/where is the definition and which version did you mean?

                            – masterxilo
                            Nov 23 '18 at 22:44











                          • @masterxilo What point are you trying to make?

                            – Thorbjørn Ravn Andersen
                            Nov 24 '18 at 1:13






                          • 2





                            I am just emphasizing that besides the Java world all of software has a fight with ensuring that correct versions of dependencies are found. I can mention dll-hell, package managers, version managers, spring boot bill of materials and docker containers as examples of this problem and possible solutions. The larger the fraction of foreign code becones the larger the problem gets.

                            – masterxilo
                            Nov 25 '18 at 14:08








                          24




                          24





                          Can you please be more eclipse specific? What do I have to do?

                          – user2426316
                          Jul 1 '13 at 16:03





                          Can you please be more eclipse specific? What do I have to do?

                          – user2426316
                          Jul 1 '13 at 16:03




                          19




                          19





                          Your question does not contain enough information to provide a more specfiic answer. Consider adding that.

                          – Thorbjørn Ravn Andersen
                          Jul 1 '13 at 16:06





                          Your question does not contain enough information to provide a more specfiic answer. Consider adding that.

                          – Thorbjørn Ravn Andersen
                          Jul 1 '13 at 16:06













                          Dependency resolution/version mismatches is a very common problem in basically all programming environments. We could say that all any program ever does is resolve such definitions... the question is always what/where is the definition and which version did you mean?

                          – masterxilo
                          Nov 23 '18 at 22:44





                          Dependency resolution/version mismatches is a very common problem in basically all programming environments. We could say that all any program ever does is resolve such definitions... the question is always what/where is the definition and which version did you mean?

                          – masterxilo
                          Nov 23 '18 at 22:44













                          @masterxilo What point are you trying to make?

                          – Thorbjørn Ravn Andersen
                          Nov 24 '18 at 1:13





                          @masterxilo What point are you trying to make?

                          – Thorbjørn Ravn Andersen
                          Nov 24 '18 at 1:13




                          2




                          2





                          I am just emphasizing that besides the Java world all of software has a fight with ensuring that correct versions of dependencies are found. I can mention dll-hell, package managers, version managers, spring boot bill of materials and docker containers as examples of this problem and possible solutions. The larger the fraction of foreign code becones the larger the problem gets.

                          – masterxilo
                          Nov 25 '18 at 14:08





                          I am just emphasizing that besides the Java world all of software has a fight with ensuring that correct versions of dependencies are found. I can mention dll-hell, package managers, version managers, spring boot bill of materials and docker containers as examples of this problem and possible solutions. The larger the fraction of foreign code becones the larger the problem gets.

                          – masterxilo
                          Nov 25 '18 at 14:08













                          38














                          A classpath is a list of locations to load classes from.



                          These 'locations' can either be directories, or jar files.



                          For directories, the JVM will follow an expected pattern for loading a class. If I have the directory C:/myproject/classes in my classpath, and I attempt to load a class com.mycompany.Foo, it will look under the classes directory for a directory called com, then under that a directory called mycompany, and finally it will look for a file called Foo.class in that directory.



                          In the second instance, for jar files, it will search the jar file for that class. A jar file is in reality just a zipped collection of directories like the above. If you unzip a jar file, you'll get a bunch of directories and class files following the pattern above.



                          So the JVM traverses a classpath from start to finish looking for the definition of the class when it attempts to load the class definition. For example, in the classpath :



                          C:/myproject/classes;C:/myproject/lib/stuff.jar;C:/myproject/lib/otherstuff.jar



                          The JVM will attempt to look in the directory classes first, then in stuff.jar and finally in otherstuff.jar.



                          When you get a ClassNotFoundException, it means the JVM has traversed the entire classpath and not found the class you've attempted to reference. The solution, as so often in the Java world, is to check your classpath.



                          You define a classpath on the command line by saying java -cp and then your classpath. In an IDE such as Eclipse, you'll have a menu option to specify your classpath.






                          share|improve this answer
























                          • But how do I actually find what my classpath is

                            – Philip Rego
                            2 days ago
















                          38














                          A classpath is a list of locations to load classes from.



                          These 'locations' can either be directories, or jar files.



                          For directories, the JVM will follow an expected pattern for loading a class. If I have the directory C:/myproject/classes in my classpath, and I attempt to load a class com.mycompany.Foo, it will look under the classes directory for a directory called com, then under that a directory called mycompany, and finally it will look for a file called Foo.class in that directory.



                          In the second instance, for jar files, it will search the jar file for that class. A jar file is in reality just a zipped collection of directories like the above. If you unzip a jar file, you'll get a bunch of directories and class files following the pattern above.



                          So the JVM traverses a classpath from start to finish looking for the definition of the class when it attempts to load the class definition. For example, in the classpath :



                          C:/myproject/classes;C:/myproject/lib/stuff.jar;C:/myproject/lib/otherstuff.jar



                          The JVM will attempt to look in the directory classes first, then in stuff.jar and finally in otherstuff.jar.



                          When you get a ClassNotFoundException, it means the JVM has traversed the entire classpath and not found the class you've attempted to reference. The solution, as so often in the Java world, is to check your classpath.



                          You define a classpath on the command line by saying java -cp and then your classpath. In an IDE such as Eclipse, you'll have a menu option to specify your classpath.






                          share|improve this answer
























                          • But how do I actually find what my classpath is

                            – Philip Rego
                            2 days ago














                          38












                          38








                          38







                          A classpath is a list of locations to load classes from.



                          These 'locations' can either be directories, or jar files.



                          For directories, the JVM will follow an expected pattern for loading a class. If I have the directory C:/myproject/classes in my classpath, and I attempt to load a class com.mycompany.Foo, it will look under the classes directory for a directory called com, then under that a directory called mycompany, and finally it will look for a file called Foo.class in that directory.



                          In the second instance, for jar files, it will search the jar file for that class. A jar file is in reality just a zipped collection of directories like the above. If you unzip a jar file, you'll get a bunch of directories and class files following the pattern above.



                          So the JVM traverses a classpath from start to finish looking for the definition of the class when it attempts to load the class definition. For example, in the classpath :



                          C:/myproject/classes;C:/myproject/lib/stuff.jar;C:/myproject/lib/otherstuff.jar



                          The JVM will attempt to look in the directory classes first, then in stuff.jar and finally in otherstuff.jar.



                          When you get a ClassNotFoundException, it means the JVM has traversed the entire classpath and not found the class you've attempted to reference. The solution, as so often in the Java world, is to check your classpath.



                          You define a classpath on the command line by saying java -cp and then your classpath. In an IDE such as Eclipse, you'll have a menu option to specify your classpath.






                          share|improve this answer













                          A classpath is a list of locations to load classes from.



                          These 'locations' can either be directories, or jar files.



                          For directories, the JVM will follow an expected pattern for loading a class. If I have the directory C:/myproject/classes in my classpath, and I attempt to load a class com.mycompany.Foo, it will look under the classes directory for a directory called com, then under that a directory called mycompany, and finally it will look for a file called Foo.class in that directory.



                          In the second instance, for jar files, it will search the jar file for that class. A jar file is in reality just a zipped collection of directories like the above. If you unzip a jar file, you'll get a bunch of directories and class files following the pattern above.



                          So the JVM traverses a classpath from start to finish looking for the definition of the class when it attempts to load the class definition. For example, in the classpath :



                          C:/myproject/classes;C:/myproject/lib/stuff.jar;C:/myproject/lib/otherstuff.jar



                          The JVM will attempt to look in the directory classes first, then in stuff.jar and finally in otherstuff.jar.



                          When you get a ClassNotFoundException, it means the JVM has traversed the entire classpath and not found the class you've attempted to reference. The solution, as so often in the Java world, is to check your classpath.



                          You define a classpath on the command line by saying java -cp and then your classpath. In an IDE such as Eclipse, you'll have a menu option to specify your classpath.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jul 1 '13 at 16:20









                          user2000590user2000590

                          38122




                          38122













                          • But how do I actually find what my classpath is

                            – Philip Rego
                            2 days ago



















                          • But how do I actually find what my classpath is

                            – Philip Rego
                            2 days ago

















                          But how do I actually find what my classpath is

                          – Philip Rego
                          2 days ago





                          But how do I actually find what my classpath is

                          – Philip Rego
                          2 days ago











                          10














                          This is the best solution I found so far.



                          Suppose we have a package called org.mypackage containing the classes:




                          • HelloWorld (main class)

                          • SupportClass

                          • UtilClass


                          and the files defining this package are stored physically under the directory D:myprogram (on Windows) or /home/user/myprogram (on Linux).



                          The file structure will look like this:
                          enter image description here



                          When we invoke Java, we specify the name of the application to run: org.mypackage.HelloWorld. However we must also tell Java where to look for the files and directories defining our package. So to launch the program, we have to use the following command:
                          enter image description here




                          NOTE: You have to execute the above java command no matter what your current location is. But this is not the case for javac. For
                          compiling you can even directly go into the directory where you have
                          your .java files and directly execute javac ClassName.java.







                          share|improve this answer






























                            10














                            This is the best solution I found so far.



                            Suppose we have a package called org.mypackage containing the classes:




                            • HelloWorld (main class)

                            • SupportClass

                            • UtilClass


                            and the files defining this package are stored physically under the directory D:myprogram (on Windows) or /home/user/myprogram (on Linux).



                            The file structure will look like this:
                            enter image description here



                            When we invoke Java, we specify the name of the application to run: org.mypackage.HelloWorld. However we must also tell Java where to look for the files and directories defining our package. So to launch the program, we have to use the following command:
                            enter image description here




                            NOTE: You have to execute the above java command no matter what your current location is. But this is not the case for javac. For
                            compiling you can even directly go into the directory where you have
                            your .java files and directly execute javac ClassName.java.







                            share|improve this answer




























                              10












                              10








                              10







                              This is the best solution I found so far.



                              Suppose we have a package called org.mypackage containing the classes:




                              • HelloWorld (main class)

                              • SupportClass

                              • UtilClass


                              and the files defining this package are stored physically under the directory D:myprogram (on Windows) or /home/user/myprogram (on Linux).



                              The file structure will look like this:
                              enter image description here



                              When we invoke Java, we specify the name of the application to run: org.mypackage.HelloWorld. However we must also tell Java where to look for the files and directories defining our package. So to launch the program, we have to use the following command:
                              enter image description here




                              NOTE: You have to execute the above java command no matter what your current location is. But this is not the case for javac. For
                              compiling you can even directly go into the directory where you have
                              your .java files and directly execute javac ClassName.java.







                              share|improve this answer















                              This is the best solution I found so far.



                              Suppose we have a package called org.mypackage containing the classes:




                              • HelloWorld (main class)

                              • SupportClass

                              • UtilClass


                              and the files defining this package are stored physically under the directory D:myprogram (on Windows) or /home/user/myprogram (on Linux).



                              The file structure will look like this:
                              enter image description here



                              When we invoke Java, we specify the name of the application to run: org.mypackage.HelloWorld. However we must also tell Java where to look for the files and directories defining our package. So to launch the program, we have to use the following command:
                              enter image description here




                              NOTE: You have to execute the above java command no matter what your current location is. But this is not the case for javac. For
                              compiling you can even directly go into the directory where you have
                              your .java files and directly execute javac ClassName.java.








                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Oct 5 '15 at 6:51

























                              answered Oct 5 '15 at 6:44









                              Ram PatraRam Patra

                              10.4k104562




                              10.4k104562























                                  6














                                  If you know the path of the class or the jar containing the class then add it to your classpath while running it. You can use the classpath as mentioned here:



                                  on Windows



                                  java -classpath .;yourjar.jar YourMainClass


                                  on UNIX/Linux



                                  java -classpath .:yourjar.jar YourMainClass





                                  share|improve this answer






























                                    6














                                    If you know the path of the class or the jar containing the class then add it to your classpath while running it. You can use the classpath as mentioned here:



                                    on Windows



                                    java -classpath .;yourjar.jar YourMainClass


                                    on UNIX/Linux



                                    java -classpath .:yourjar.jar YourMainClass





                                    share|improve this answer




























                                      6












                                      6








                                      6







                                      If you know the path of the class or the jar containing the class then add it to your classpath while running it. You can use the classpath as mentioned here:



                                      on Windows



                                      java -classpath .;yourjar.jar YourMainClass


                                      on UNIX/Linux



                                      java -classpath .:yourjar.jar YourMainClass





                                      share|improve this answer















                                      If you know the path of the class or the jar containing the class then add it to your classpath while running it. You can use the classpath as mentioned here:



                                      on Windows



                                      java -classpath .;yourjar.jar YourMainClass


                                      on UNIX/Linux



                                      java -classpath .:yourjar.jar YourMainClass






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Jul 1 '13 at 16:05

























                                      answered Jul 1 '13 at 16:00









                                      Juned AhsanJuned Ahsan

                                      55.3k970105




                                      55.3k970105























                                          4














                                          Try these if you use maven. I use maven for my project and when I do mvn clean install and try to run a program it throws the exception. So, I clean the project and run it again and it works for me.



                                          I use eclipse IDE.



                                          For Class Not Found Exception when running Junit test, try running mvn clean test once. It will compile all the test classes.






                                          share|improve this answer


























                                          • what directory were you in when you ran "mvn clean test"? is it in the same directory as the POM?

                                            – TacoB0t
                                            Mar 27 '18 at 16:19






                                          • 1





                                            Yes. Ran it from the directory where pom file is present.

                                            – Arun
                                            Mar 27 '18 at 18:26
















                                          4














                                          Try these if you use maven. I use maven for my project and when I do mvn clean install and try to run a program it throws the exception. So, I clean the project and run it again and it works for me.



                                          I use eclipse IDE.



                                          For Class Not Found Exception when running Junit test, try running mvn clean test once. It will compile all the test classes.






                                          share|improve this answer


























                                          • what directory were you in when you ran "mvn clean test"? is it in the same directory as the POM?

                                            – TacoB0t
                                            Mar 27 '18 at 16:19






                                          • 1





                                            Yes. Ran it from the directory where pom file is present.

                                            – Arun
                                            Mar 27 '18 at 18:26














                                          4












                                          4








                                          4







                                          Try these if you use maven. I use maven for my project and when I do mvn clean install and try to run a program it throws the exception. So, I clean the project and run it again and it works for me.



                                          I use eclipse IDE.



                                          For Class Not Found Exception when running Junit test, try running mvn clean test once. It will compile all the test classes.






                                          share|improve this answer















                                          Try these if you use maven. I use maven for my project and when I do mvn clean install and try to run a program it throws the exception. So, I clean the project and run it again and it works for me.



                                          I use eclipse IDE.



                                          For Class Not Found Exception when running Junit test, try running mvn clean test once. It will compile all the test classes.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Sep 5 '18 at 6:29

























                                          answered Apr 22 '15 at 19:48









                                          ArunArun

                                          1,17711326




                                          1,17711326













                                          • what directory were you in when you ran "mvn clean test"? is it in the same directory as the POM?

                                            – TacoB0t
                                            Mar 27 '18 at 16:19






                                          • 1





                                            Yes. Ran it from the directory where pom file is present.

                                            – Arun
                                            Mar 27 '18 at 18:26



















                                          • what directory were you in when you ran "mvn clean test"? is it in the same directory as the POM?

                                            – TacoB0t
                                            Mar 27 '18 at 16:19






                                          • 1





                                            Yes. Ran it from the directory where pom file is present.

                                            – Arun
                                            Mar 27 '18 at 18:26

















                                          what directory were you in when you ran "mvn clean test"? is it in the same directory as the POM?

                                          – TacoB0t
                                          Mar 27 '18 at 16:19





                                          what directory were you in when you ran "mvn clean test"? is it in the same directory as the POM?

                                          – TacoB0t
                                          Mar 27 '18 at 16:19




                                          1




                                          1





                                          Yes. Ran it from the directory where pom file is present.

                                          – Arun
                                          Mar 27 '18 at 18:26





                                          Yes. Ran it from the directory where pom file is present.

                                          – Arun
                                          Mar 27 '18 at 18:26











                                          3














                                          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.






                                          share|improve this answer






























                                            3














                                            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.






                                            share|improve this answer




























                                              3












                                              3








                                              3







                                              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.






                                              share|improve this answer















                                              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.







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Jul 1 '13 at 16:23









                                              Imane Fateh

                                              2,17531221




                                              2,17531221










                                              answered Jul 1 '13 at 16:05









                                              invictvs1invictvs1

                                              119315




                                              119315























                                                  3














                                                  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.






                                                  share|improve this answer



















                                                  • 5





                                                    That is on windows (semicolon) , on unix/linux it is ':' (colon)

                                                    – Joeblade
                                                    Jan 19 '15 at 8:38
















                                                  3














                                                  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.






                                                  share|improve this answer



















                                                  • 5





                                                    That is on windows (semicolon) , on unix/linux it is ':' (colon)

                                                    – Joeblade
                                                    Jan 19 '15 at 8:38














                                                  3












                                                  3








                                                  3







                                                  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.






                                                  share|improve this answer













                                                  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.







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Jan 19 '15 at 8:33









                                                  Kiran S KulkarniKiran S Kulkarni

                                                  100211




                                                  100211








                                                  • 5





                                                    That is on windows (semicolon) , on unix/linux it is ':' (colon)

                                                    – Joeblade
                                                    Jan 19 '15 at 8:38














                                                  • 5





                                                    That is on windows (semicolon) , on unix/linux it is ':' (colon)

                                                    – Joeblade
                                                    Jan 19 '15 at 8:38








                                                  5




                                                  5





                                                  That is on windows (semicolon) , on unix/linux it is ':' (colon)

                                                  – Joeblade
                                                  Jan 19 '15 at 8:38





                                                  That is on windows (semicolon) , on unix/linux it is ':' (colon)

                                                  – Joeblade
                                                  Jan 19 '15 at 8:38











                                                  3














                                                  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 -cpwith 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






                                                  share|improve this answer


























                                                  • Only unzipping the JAR worked for me, none of the other solutions did

                                                    – OverCoder
                                                    Jun 5 '16 at 23:05
















                                                  3














                                                  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 -cpwith 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






                                                  share|improve this answer


























                                                  • Only unzipping the JAR worked for me, none of the other solutions did

                                                    – OverCoder
                                                    Jun 5 '16 at 23:05














                                                  3












                                                  3








                                                  3







                                                  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 -cpwith 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






                                                  share|improve this answer















                                                  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 -cpwith 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







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited Dec 4 '15 at 9:10

























                                                  answered Dec 4 '15 at 9:05









                                                  Annonnymous PersonAnnonnymous Person

                                                  312




                                                  312













                                                  • Only unzipping the JAR worked for me, none of the other solutions did

                                                    – OverCoder
                                                    Jun 5 '16 at 23:05



















                                                  • Only unzipping the JAR worked for me, none of the other solutions did

                                                    – OverCoder
                                                    Jun 5 '16 at 23:05

















                                                  Only unzipping the JAR worked for me, none of the other solutions did

                                                  – OverCoder
                                                  Jun 5 '16 at 23:05





                                                  Only unzipping the JAR worked for me, none of the other solutions did

                                                  – OverCoder
                                                  Jun 5 '16 at 23:05











                                                  2














                                                  Go up to the top and remove the import statement if there is one, and re import the class. But if that isn't the case do a clean then build. Are you using Netbeans or Eclipse?






                                                  share|improve this answer




























                                                    2














                                                    Go up to the top and remove the import statement if there is one, and re import the class. But if that isn't the case do a clean then build. Are you using Netbeans or Eclipse?






                                                    share|improve this answer


























                                                      2












                                                      2








                                                      2







                                                      Go up to the top and remove the import statement if there is one, and re import the class. But if that isn't the case do a clean then build. Are you using Netbeans or Eclipse?






                                                      share|improve this answer













                                                      Go up to the top and remove the import statement if there is one, and re import the class. But if that isn't the case do a clean then build. Are you using Netbeans or Eclipse?







                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered Jul 1 '13 at 16:04









                                                      yamsyams

                                                      14331952




                                                      14331952























                                                          2














                                                          I ran into this as well and tried all of the other solutions. I did not have the .class file in my HTML folder, I only had the .java file. Once I added the .class file the program worked fine.






                                                          share|improve this answer




























                                                            2














                                                            I ran into this as well and tried all of the other solutions. I did not have the .class file in my HTML folder, I only had the .java file. Once I added the .class file the program worked fine.






                                                            share|improve this answer


























                                                              2












                                                              2








                                                              2







                                                              I ran into this as well and tried all of the other solutions. I did not have the .class file in my HTML folder, I only had the .java file. Once I added the .class file the program worked fine.






                                                              share|improve this answer













                                                              I ran into this as well and tried all of the other solutions. I did not have the .class file in my HTML folder, I only had the .java file. Once I added the .class file the program worked fine.







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered Jan 13 '14 at 15:35









                                                              Jason RobertsonJason Robertson

                                                              211




                                                              211























                                                                  2















                                                                  1. It could happen if your classpath is not correct


                                                                  2. Let us posit a serializable class and deserializable class under same projectname. You run the serializable class, creating a serializable object in specific folder. Now you need the desearialized data. In the meantime, if you change the name of the project it will not work. You have to run the serializable class first and then deserialize the file.







                                                                  share|improve this answer






























                                                                    2















                                                                    1. It could happen if your classpath is not correct


                                                                    2. Let us posit a serializable class and deserializable class under same projectname. You run the serializable class, creating a serializable object in specific folder. Now you need the desearialized data. In the meantime, if you change the name of the project it will not work. You have to run the serializable class first and then deserialize the file.







                                                                    share|improve this answer




























                                                                      2












                                                                      2








                                                                      2








                                                                      1. It could happen if your classpath is not correct


                                                                      2. Let us posit a serializable class and deserializable class under same projectname. You run the serializable class, creating a serializable object in specific folder. Now you need the desearialized data. In the meantime, if you change the name of the project it will not work. You have to run the serializable class first and then deserialize the file.







                                                                      share|improve this answer
















                                                                      1. It could happen if your classpath is not correct


                                                                      2. Let us posit a serializable class and deserializable class under same projectname. You run the serializable class, creating a serializable object in specific folder. Now you need the desearialized data. In the meantime, if you change the name of the project it will not work. You have to run the serializable class first and then deserialize the file.








                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited Feb 10 '14 at 22:24









                                                                      Nathaniel Ford

                                                                      13.7k155675




                                                                      13.7k155675










                                                                      answered Feb 10 '14 at 22:05









                                                                      Omar Faroque AnikOmar Faroque Anik

                                                                      1,9622130




                                                                      1,9622130























                                                                          2














                                                                          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..






                                                                          share|improve this answer




























                                                                            2














                                                                            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..






                                                                            share|improve this answer


























                                                                              2












                                                                              2








                                                                              2







                                                                              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..






                                                                              share|improve this answer













                                                                              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..







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered Jan 11 '17 at 8:16









                                                                              ibrahimgunesibrahimgunes

                                                                              967




                                                                              967























                                                                                  2














                                                                                  I just did



                                                                                  1.Invalidate caches and restart



                                                                                  2.Rebuilt my project which solved the problem






                                                                                  share|improve this answer




























                                                                                    2














                                                                                    I just did



                                                                                    1.Invalidate caches and restart



                                                                                    2.Rebuilt my project which solved the problem






                                                                                    share|improve this answer


























                                                                                      2












                                                                                      2








                                                                                      2







                                                                                      I just did



                                                                                      1.Invalidate caches and restart



                                                                                      2.Rebuilt my project which solved the problem






                                                                                      share|improve this answer













                                                                                      I just did



                                                                                      1.Invalidate caches and restart



                                                                                      2.Rebuilt my project which solved the problem







                                                                                      share|improve this answer












                                                                                      share|improve this answer



                                                                                      share|improve this answer










                                                                                      answered Feb 19 '18 at 11:27









                                                                                      Jyoti JKJyoti JK

                                                                                      1,5971728




                                                                                      1,5971728























                                                                                          1














                                                                                          I was trying to run .jar from C# code using Process class. The java code ran successfully from eclipse but it doesn't from C# visual studio and even clicking directly on the jar file, it always stopped with ClassNotFoundException: exception. Solution for my, was export the java program as "Runnable JAR file" instead of "JAR File". Hope it can help someone.






                                                                                          share|improve this answer




























                                                                                            1














                                                                                            I was trying to run .jar from C# code using Process class. The java code ran successfully from eclipse but it doesn't from C# visual studio and even clicking directly on the jar file, it always stopped with ClassNotFoundException: exception. Solution for my, was export the java program as "Runnable JAR file" instead of "JAR File". Hope it can help someone.






                                                                                            share|improve this answer


























                                                                                              1












                                                                                              1








                                                                                              1







                                                                                              I was trying to run .jar from C# code using Process class. The java code ran successfully from eclipse but it doesn't from C# visual studio and even clicking directly on the jar file, it always stopped with ClassNotFoundException: exception. Solution for my, was export the java program as "Runnable JAR file" instead of "JAR File". Hope it can help someone.






                                                                                              share|improve this answer













                                                                                              I was trying to run .jar from C# code using Process class. The java code ran successfully from eclipse but it doesn't from C# visual studio and even clicking directly on the jar file, it always stopped with ClassNotFoundException: exception. Solution for my, was export the java program as "Runnable JAR file" instead of "JAR File". Hope it can help someone.







                                                                                              share|improve this answer












                                                                                              share|improve this answer



                                                                                              share|improve this answer










                                                                                              answered Feb 14 '18 at 13:24









                                                                                              Dani AyaDani Aya

                                                                                              1158




                                                                                              1158























                                                                                                  1














                                                                                                  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)






                                                                                                  share|improve this answer




























                                                                                                    1














                                                                                                    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)






                                                                                                    share|improve this answer


























                                                                                                      1












                                                                                                      1








                                                                                                      1







                                                                                                      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)






                                                                                                      share|improve this answer













                                                                                                      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)







                                                                                                      share|improve this answer












                                                                                                      share|improve this answer



                                                                                                      share|improve this answer










                                                                                                      answered Apr 3 '18 at 14:03









                                                                                                      s5ss5s

                                                                                                      2,429114583




                                                                                                      2,429114583























                                                                                                          0














                                                                                                          If you have added multiple (Third-Party)**libraries and Extends **Application class



                                                                                                          Then it might occur.



                                                                                                          For that, you have to set multiDexEnabled true and replace your extended Application class with MultiDexApplication.



                                                                                                          It will be solved.






                                                                                                          share|improve this answer




























                                                                                                            0














                                                                                                            If you have added multiple (Third-Party)**libraries and Extends **Application class



                                                                                                            Then it might occur.



                                                                                                            For that, you have to set multiDexEnabled true and replace your extended Application class with MultiDexApplication.



                                                                                                            It will be solved.






                                                                                                            share|improve this answer


























                                                                                                              0












                                                                                                              0








                                                                                                              0







                                                                                                              If you have added multiple (Third-Party)**libraries and Extends **Application class



                                                                                                              Then it might occur.



                                                                                                              For that, you have to set multiDexEnabled true and replace your extended Application class with MultiDexApplication.



                                                                                                              It will be solved.






                                                                                                              share|improve this answer













                                                                                                              If you have added multiple (Third-Party)**libraries and Extends **Application class



                                                                                                              Then it might occur.



                                                                                                              For that, you have to set multiDexEnabled true and replace your extended Application class with MultiDexApplication.



                                                                                                              It will be solved.







                                                                                                              share|improve this answer












                                                                                                              share|improve this answer



                                                                                                              share|improve this answer










                                                                                                              answered Sep 22 '18 at 9:41









                                                                                                              Parth PatelParth Patel

                                                                                                              53069




                                                                                                              53069























                                                                                                                  0














                                                                                                                  Basic Generic Question - Simplest Generic Answer ;)



                                                                                                                  Given the information I will make the assumption that you might be trying a basic approach to coding, building/compiling and running a simple console app like "Hello World", using some simple text editor and some Command Shell.



                                                                                                                  This error occurs in the fallowing scenario:



                                                                                                                  ..SomePath>javac HelloWorld.java
                                                                                                                  ..SomePath>java HelloWorld.class


                                                                                                                  In other words, use:



                                                                                                                  ..SomePath>java HelloWorld


                                                                                                                  P.S. The adding the file extension .class produces the same mistake.
                                                                                                                  Also be sure to have the Java's (JDK/JRE) bin folder in the operating system's Environment Variables's PATH.(Lookup for more details other posts on this)
                                                                                                                  P.P.S Was I correct in my assumption/s?






                                                                                                                  share|improve this answer




























                                                                                                                    0














                                                                                                                    Basic Generic Question - Simplest Generic Answer ;)



                                                                                                                    Given the information I will make the assumption that you might be trying a basic approach to coding, building/compiling and running a simple console app like "Hello World", using some simple text editor and some Command Shell.



                                                                                                                    This error occurs in the fallowing scenario:



                                                                                                                    ..SomePath>javac HelloWorld.java
                                                                                                                    ..SomePath>java HelloWorld.class


                                                                                                                    In other words, use:



                                                                                                                    ..SomePath>java HelloWorld


                                                                                                                    P.S. The adding the file extension .class produces the same mistake.
                                                                                                                    Also be sure to have the Java's (JDK/JRE) bin folder in the operating system's Environment Variables's PATH.(Lookup for more details other posts on this)
                                                                                                                    P.P.S Was I correct in my assumption/s?






                                                                                                                    share|improve this answer


























                                                                                                                      0












                                                                                                                      0








                                                                                                                      0







                                                                                                                      Basic Generic Question - Simplest Generic Answer ;)



                                                                                                                      Given the information I will make the assumption that you might be trying a basic approach to coding, building/compiling and running a simple console app like "Hello World", using some simple text editor and some Command Shell.



                                                                                                                      This error occurs in the fallowing scenario:



                                                                                                                      ..SomePath>javac HelloWorld.java
                                                                                                                      ..SomePath>java HelloWorld.class


                                                                                                                      In other words, use:



                                                                                                                      ..SomePath>java HelloWorld


                                                                                                                      P.S. The adding the file extension .class produces the same mistake.
                                                                                                                      Also be sure to have the Java's (JDK/JRE) bin folder in the operating system's Environment Variables's PATH.(Lookup for more details other posts on this)
                                                                                                                      P.P.S Was I correct in my assumption/s?






                                                                                                                      share|improve this answer













                                                                                                                      Basic Generic Question - Simplest Generic Answer ;)



                                                                                                                      Given the information I will make the assumption that you might be trying a basic approach to coding, building/compiling and running a simple console app like "Hello World", using some simple text editor and some Command Shell.



                                                                                                                      This error occurs in the fallowing scenario:



                                                                                                                      ..SomePath>javac HelloWorld.java
                                                                                                                      ..SomePath>java HelloWorld.class


                                                                                                                      In other words, use:



                                                                                                                      ..SomePath>java HelloWorld


                                                                                                                      P.S. The adding the file extension .class produces the same mistake.
                                                                                                                      Also be sure to have the Java's (JDK/JRE) bin folder in the operating system's Environment Variables's PATH.(Lookup for more details other posts on this)
                                                                                                                      P.P.S Was I correct in my assumption/s?







                                                                                                                      share|improve this answer












                                                                                                                      share|improve this answer



                                                                                                                      share|improve this answer










                                                                                                                      answered Feb 13 at 18:43









                                                                                                                      VasilVasil

                                                                                                                      1115




                                                                                                                      1115























                                                                                                                          -4














                                                                                                                          Put all the code in try block then catch exception in a catch block



                                                                                                                          try
                                                                                                                          {
                                                                                                                          // code
                                                                                                                          }
                                                                                                                          catch(ClassNotFoundException e1)
                                                                                                                          {
                                                                                                                          e1.getmessage();
                                                                                                                          }





                                                                                                                          share|improve this answer





















                                                                                                                          • 2





                                                                                                                            This does not resolve the exception. This hides the exception. Furthermore, "e1.getmessage()" is a) the wrong capitalisation of getMessage() and b) not going to do very much as it returns a string with a message and you're not printing it or logging it or anything!

                                                                                                                            – IBBoard
                                                                                                                            Aug 30 '16 at 12:15
















                                                                                                                          -4














                                                                                                                          Put all the code in try block then catch exception in a catch block



                                                                                                                          try
                                                                                                                          {
                                                                                                                          // code
                                                                                                                          }
                                                                                                                          catch(ClassNotFoundException e1)
                                                                                                                          {
                                                                                                                          e1.getmessage();
                                                                                                                          }





                                                                                                                          share|improve this answer





















                                                                                                                          • 2





                                                                                                                            This does not resolve the exception. This hides the exception. Furthermore, "e1.getmessage()" is a) the wrong capitalisation of getMessage() and b) not going to do very much as it returns a string with a message and you're not printing it or logging it or anything!

                                                                                                                            – IBBoard
                                                                                                                            Aug 30 '16 at 12:15














                                                                                                                          -4












                                                                                                                          -4








                                                                                                                          -4







                                                                                                                          Put all the code in try block then catch exception in a catch block



                                                                                                                          try
                                                                                                                          {
                                                                                                                          // code
                                                                                                                          }
                                                                                                                          catch(ClassNotFoundException e1)
                                                                                                                          {
                                                                                                                          e1.getmessage();
                                                                                                                          }





                                                                                                                          share|improve this answer















                                                                                                                          Put all the code in try block then catch exception in a catch block



                                                                                                                          try
                                                                                                                          {
                                                                                                                          // code
                                                                                                                          }
                                                                                                                          catch(ClassNotFoundException e1)
                                                                                                                          {
                                                                                                                          e1.getmessage();
                                                                                                                          }






                                                                                                                          share|improve this answer














                                                                                                                          share|improve this answer



                                                                                                                          share|improve this answer








                                                                                                                          edited Feb 24 '15 at 1:48









                                                                                                                          C. Leung

                                                                                                                          4,74521431




                                                                                                                          4,74521431










                                                                                                                          answered Feb 23 '15 at 15:53









                                                                                                                          sharukhsharukh

                                                                                                                          17




                                                                                                                          17








                                                                                                                          • 2





                                                                                                                            This does not resolve the exception. This hides the exception. Furthermore, "e1.getmessage()" is a) the wrong capitalisation of getMessage() and b) not going to do very much as it returns a string with a message and you're not printing it or logging it or anything!

                                                                                                                            – IBBoard
                                                                                                                            Aug 30 '16 at 12:15














                                                                                                                          • 2





                                                                                                                            This does not resolve the exception. This hides the exception. Furthermore, "e1.getmessage()" is a) the wrong capitalisation of getMessage() and b) not going to do very much as it returns a string with a message and you're not printing it or logging it or anything!

                                                                                                                            – IBBoard
                                                                                                                            Aug 30 '16 at 12:15








                                                                                                                          2




                                                                                                                          2





                                                                                                                          This does not resolve the exception. This hides the exception. Furthermore, "e1.getmessage()" is a) the wrong capitalisation of getMessage() and b) not going to do very much as it returns a string with a message and you're not printing it or logging it or anything!

                                                                                                                          – IBBoard
                                                                                                                          Aug 30 '16 at 12:15





                                                                                                                          This does not resolve the exception. This hides the exception. Furthermore, "e1.getmessage()" is a) the wrong capitalisation of getMessage() and b) not going to do very much as it returns a string with a message and you're not printing it or logging it or anything!

                                                                                                                          – IBBoard
                                                                                                                          Aug 30 '16 at 12:15





                                                                                                                          protected by Community Jul 9 '16 at 17:57



                                                                                                                          Thank you for your interest in this question.
                                                                                                                          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                                                                                          Would you like to answer one of these unanswered questions instead?



                                                                                                                          Popular posts from this blog

                                                                                                                          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                                                                                                                          Alcedinidae

                                                                                                                          RAC Tourist Trophy