Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes my java clascompile but not run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "my java clascompile but not run" Watch "my java clascompile but not run" New topic
Author

my java clascompile but not run

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1070
i wrote a java class.and i try to compile and run it.
but it compile not run.it gives class not found error.i

i set the classpath to the java "bin".
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18505
    
  40

i set the classpath to the java "bin".


The classpath is used to find the Java classes -- not to find the java compiler or JVM. So, unless you happen to also placed your compiled classfiles in the bin directory, this is wrong.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



Aruna,

As Henry pointed , you should not place classes under bin.Check out this common issues
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1070
no i didn't put my class files in bin director.
my class is in Desktop .I compiled it .It compiles with no errors.
but when i am goging to run it says classNoFound error.

I already have set the classpath to the java bin directory and JAVA_HOME to the JDK folder.
what is the reason for this error?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

aruna sameera wrote:I already have set the classpath to the java bin directory

The PATH should include the Java bin directory, and not the CLASSPATH. That should be the directory where your class files are located (or at least the current directory, .)
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1070
Thanks Rob
Finaly it works.I set the classpath tothe current Directory.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: my java clascompile but not run
 
Similar Threads
Java ME & iOS
Compilation
problem with running the java code
Notepad with compile/Run
error in running first java code