0
votes

enter image description here

Im getting this error when I try to run HelloWorld.class

From this it looks like it's trying to run HelloWorld/class. The program should simply print out HelloWorld!.

package threads;

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Any ideas?

1
I think it is not the correct way to run java from command line. See this answer stackoverflow.com/questions/16137713/…Victor M Herasme Perez
I have done exactly that. Im first compiling the java-file with javac.exe then I'm running the class-file with java.exe. Im still getting this error..Slamdunk

1 Answers

0
votes

Check your classpath: Select Start > Control Panel > System > Advanced > Environment Variables > System Variables > CLASSPATH. You can make a new variable there OR in the command prompt type: SET CLASSPATH=.;C:\Program Files\Java\jdk-10.0.2(or whatever version you are using)\bin.

Type: cd C:\Users\David\Desktop\eclipse\JNP\bin\threads this is your DIRECTORY NOT your CLASSPATH

Type: javac HelloWorld.java a class file named HelloWorld.CLASS should appear in the threads folder. Type: java HelloWorld

Also make sure you have named the file HelloWorld.java

I hope this helped!