-2

I don't know why I can't run compiled java class. Even very simple. Please see below.

C:\javatest>echo %CLASSPATH%
C:\Program Files\Java\jdk1.7.0_45\bin; C:\Program Files\Java\jdk1.7.0_45\jre\bin


C:\javatest>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.7.0_45

C:\javatest>cat hello.java
class hello{
public static void main(String[] agrs){
    System.out.println("Hello world");
}
}
C:\javatest>javac hello.java

C:\javatest>java hello.class
Error: Could not find or load main class hello.class

C:\javatest>java -cp . hello.class
Error: Could not find or load main class hello.class

C:\javatest>

JAVA in windows path C:\Program Files\Java\jdk1.7.0_45\bin

Please help.

EDITED

C:\javatest>java hello
Error: Could not find or load main class hello

C:\javatest>java.exe hello
Error: Could not find or load main class hello
2
  • Why you are still working in command prompt.Havent you heard about eclipse? Commented Nov 17, 2013 at 11:09
  • Is version number is showing with javac -version and java -version? Commented Nov 17, 2013 at 11:36

1 Answer 1

4

Use command like:

C:\javatest>java hello  //Don't enter .class extension
Sign up to request clarification or add additional context in comments.

4 Comments

Downvoter, please comment.
C:\javatest>java hello Error: Could not find or load main class hello C:\javatest>java.exe hello Error: Could not find or load main class hello
C:\Program Files\Java\jdk1.7.0_45\bin is enogh. Remove the path C:\Program Files\Java\jdk1.7.0_45\jre\bin from Environmental variable
What I had to do is to run { java -cp . hello } thanks for Your help

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.