Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (13.1k points)

Can anyone help me with the below code, it is throwing an error:

public class HelloWorld {

    public static void main(String args[]) {

        System.out.println("Hello World!"); 



CLASSPATH C:\Program Files\Java\jdk1.6.0_18\bin\

Path C:\Program Files\Java\jdk1.6.0_18\bin\

JAVAHOME C:\Program Files\Java\jdk1.6.0_18\bin

Any help would be appreciated.

1 Answer

0 votes
by (26.7k points)

Basically, in this error, java tries to find the .class file in your current directory, so you need to change the directory something like this:

cd c:\java  

And then, execute this command, will help:

java -classpath . HelloWorld 

I hope this will help.

Want to become a Java Expert? Join Java Certification now!!

Want to know more about Java? Watch this tutorial on Java Course | Java Tutorial for Beginners:

Related questions

0 votes
1 answer
asked Feb 18, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories