no java programs are running although programs geting complied
im new to java just intalled JDK 1.6
following thing
rightclick my comp->advanced->envoirnment variables
CLASSPATH-> edit C:\Program Files\Java\jdk1.6.0_01\jre\lib\rt.jar
new
JAVA_HOME->C:\Program Files\Java\jdk1.6.0_01
then i saved my file in C:\Program Files\Java\jdk1.6.0_01\bin
so file got compiled and a class file hello.class was created
but on running it using java hello it was giving error that main
exception in thread "main" java.lang.noclassdefinationfounderror:hello
wat to do?
[569 byte] By [
amit_garga] at [2007-11-27 8:40:04]

that means you dont have a main method.
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello Java");
}
}
try compiling it now
> i had to delete the classpath and java_home system
> variables and then set the "path" variable in user
> variables to
>
> C:\Program Files\Java\jre1.6.0_01\bin;C:\Program
> Files\Java\jdk1.6.0_01\bin
Glad to see that the problem is solved. Just for future reference, you do not need both of these on you're path. You only need "C:\Program Files\Java\jdk1.6.0_01\bin". The problem you were having before is that the java compiler (javac) by default searches the current directory (".") for classes as if it were on the classpath, but the java interpreter (java) only searches the current directory for classes if it is on the classpath. If your classpath is not set, however, the default is the current directory. The reason it is working now is because you unset the classpath, so its value defaulted to the current directory, and the java interpreter was able to locate the class you were trying to execute.
As a side note, you also don't need have "C:\Program Files\Java\jdk1.6.0_01\jre\lib\rt.jar" on the classpath because the .jar files in the JRE\lib and JRE\lib\ext are automatically searched for classes by javac and java. (I think JRE\lib\ext contains non-standard libraries which, if used, may produce java programs that will only run on other platforms which also have the libraries. I believe this directory is most commonly used for optional or extension packages to the JDK (such as the Java Cryptography Extension) or in conjunction with the Servlet and JSP API or commercial Database APIs as a place to put libraries with no home or as a predefined place to put libraries to prevent the classpath from becoming cluttered.)
@modia at 2007-7-12 20:38:21 >
