Hello everyone, I installed jdk1.5.0_06 and as per sun installation guide i added java\jdk1.5.0_06\bin etc. to class path. I tried the following commands at command promt c:\> java - verion and it's worked. when i tried c:\> javac it is giving 'javac' is not recognized as an internal or external command,operable program or batch file. if i tried it at promt C:\Program Files\Java\jdk1.5.0_06\bin> javac it is giving all it's options. if i try C:\Program Files\Java\jdk1.5.0_06\bin> javac hellowworld.java It is giving "error: error reading C:\Program Files\Java\jdk1.5.0_06\bin\javac.exe; error in opening zip file"
Why i can't compile a program? I added every thing to classpath.
There are two different environment variables we are talking about.
One is PATH. Windows uses it to find programs to run. The entries are directories in which *.EXE files can be found.
The other is CLASSPATH. Java uses it to find *.CLASS files to load. The entries are *.JAR files containing classes, or directories containing classes.
For someone just starting out in Java, PATH should include an entry for "C:\Program Files\Java\jdk1.5.0_06\bin\". CLASSPATH should not be defined. If you have a definition for CLASSPATH, delete it.
Note that the example you just showed above, with all the *.EXE files listed, is completely incorrect no matter what variable you're talkiing about. Neither PATH nor CLASSPATH would ever include *.EXE files.
thanks. i removed .exe files from my class path . now javac is working . i am able to compile .java and no errors. but when i say c:\> java helloworld it is giving error"Exception in thread "main" java.lang.NoClassDefFoundError: helloworld/class"
Originally posted by sapna manga: thanks. i removed .exe files from my class path . now javac is working . i am able to compile .java and no errors. but when i say c:\> java helloworld it is giving error"Exception in thread "main" java.lang.NoClassDefFoundError: helloworld/class"
How can i get rid of it?
if u are in C:\ then you have to make sure the helloworld.java file is there in c:> itslef else it will give this error ... u hv to be in folder in which u have the .java file in order to compile and run it ....