• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java run time error

 
indiver kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please somebody help me....i am a java learner.....i am facing a problem.....


when i run my java program java test

it shows a error error:could not find or load main class :test

or when i use this command java -cp . test
it give the result....


what's the problem with this....

 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Have you set a classpath in your computer? That is usually a mistake.
If you set the classpath yourself, record it somewhere and delete it completely.
If the classpath was set before you installed Java (which often means you have installed Quicktime), add the following to the start of the classpath:-
On windows:-On other OSs, eg Linux, Mac, Unix:-What is happening is that the Java runtime is looking in all sorts of folders for the file you want, and not in the . folder. If you get rid of the classpath, it sill use . as a default classpath.
 
Junilu Lacar
Bartender
Pie
Posts: 7298
44
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the file name and the capitalization in your code. Following standard conventions, you should have these files:
Test.java
Test.class

and your Test.java should have this line:

Then run with the command 'java Test' (with a capital T)
 
indiver kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for all......my problem has been solved...
 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what was the problem?
 
indiver kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
problem is just of setting enviornmental varriable in a correct manner.....thanks to you for this.....
 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thought so! You’re welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic