How do I resolve ClassNotFoundException?

前端 未结 22 1455
后悔当初
后悔当初 2020-11-21 06:06

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

java.lang.ClassNotFoundException:

After the colon comes the location of the cla

22条回答
  •  余生分开走
    2020-11-21 06:36

    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?

提交回复
热议问题