cmd prompt exception "could not find or load main class test.java"
Hello, I'm getting the exception in cmd prompt while running the java program even after it is compiled successfully. I don't know why it can't find the .class file when .java file was available a moment before. I read so many threads relating to this exception and i also did as they said to recreate new java file and compile and run it. But then also it is not working properly. It was working good before 3 months. From last three months this exception has become permanent. Please help me to run files through command prompt. Since it is not working i'm using netbeans now
Thanks in advance
Re: cmd prompt exception "could not find or load main class test.java"
Did you use the javac command to compile the program:
javac test.java
if there is no error message, the above creates a test.class file
To execute that code enter:
java test
If there are problems:
On Windows: To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
Re: cmd prompt exception "could not find or load main class test.java"
Hello, Thank you for your solution i did as you said but i'm getting this error again. The below Text is copied from command prompt as u said.
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\VJS>I:
I:\>cd softys
I:\Softys>cd java
I:\Softys\java>cd javademos
I:\Softys\java\javademos>cd\
I:\>javac test.java
I:\>java test
Error: Could not find or load main class test
I:\>
I've also reinstalled the whole java1.6 more than 5 times by removing completely but this exception is appearing always.
Re: cmd prompt exception "could not find or load main class test.java"
What is in the file: test.java?
Did the compiling of test.java create a test.class file? Use the dir command to see what is in the folder with the test.java file.
Re: cmd prompt exception "could not find or load main class test.java"
Thank you again for suggesting me solution. I put that program with .java extension to one folder and compiled now its working fine. A lot of thank for you. :)