Sumit Rai wrote:1. javac is not recognised as an internal or external command... [ I solved this problem ]
My DOS command goes like this :
C:\Program Files\Java\jdk1.6.0_23\bin>javac HelloWorld.java
2. but now it shows some error in creating .class extension.... It says this :
HelloWorld.java:1: error while writing HelloWorld: HelloWorld.class (access is denied)
public class HelloWorld {
^
1 error
3. And what does the symbol "^" means below the letter "c" of class ?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4
SCWCD
Navneet Singh wrote:It would be better if you could post your program. You can create environment variable in your system property which will evade the problem of always going to the path of java bin directory.
SCJP 1.4
SCWCD
Navneet Singh wrote:setting up environment variable (on windows)
go to start-My Computer (right click) - go to properties - go to 'Advanced' tab - click on 'Environment Variables' - you will find two sections (one is 'user variables for My Computer' and the other is 'System Variables') - in 'System Variables' section click on 'New' - type 'variable name' as 'JAVA_HOME' and 'variable value' as 'path till java_bin directory' - click on 'OK' - then inside 'system variables' section double click on 'path' as variable(it should be there) - then edit that section and go to the end of it and then type : ';%JAVA_HOME%'
Now you java is set in environment variable. Now exit all your command prompt. Open fresh/new command prompt and write 'javac -version'- it will give you the version. It means it is properly installed in your environment variable.
Your code looks right, try this option and check.
Rob Spoor wrote:
Sumit Rai wrote:1. javac is not recognised as an internal or external command... [ I solved this problem ]
You can also add the JDK's bin folder to your PATH variable. You can use our search if you don't know how to. It's a question that has shown up multiple times already.
My DOS command goes like this :
C:\Program Files\Java\jdk1.6.0_23\bin>javac HelloWorld.java
I highly discourage putting your source files in your JDK's folder or any of its sub folders. Create a dedicated folder for all your development work, with sub folders for each project. For instance, C:\Projects will hold all projects. Inside you have folder HelloWorld which is where the HelloWorld.java file should go. If you've set the PATH correctly, you can just type "javac HelloWorld.java" from this folder.
2. but now it shows some error in creating .class extension.... It says this :
HelloWorld.java:1: error while writing HelloWorld: HelloWorld.class (access is denied)
You're probably using Windows Vista or Windows 7. User Access Control is blocking the writing of files to most of the Program Files folder and its sub folders without confirmation. Unfortunately, javac doesn't ask for confirmation but fails instead.
By putting your files in the dedicated folder and making sure you have write-rights on it, you should get rid of this error.
public class HelloWorld {
^
1 error
3. And what does the symbol "^" means below the letter "c" of class ?
It's an indicator that shows where in your line the error occurs. Usually, like when you have a syntax error, it's very helpful, but in this case it's not.
SCJP 1.4
SCWCD
Sumit Rai wrote: 1. If I directly give path as C:\Jprojects // which is the folder I have created..
It says same " javac not recognised...".
2. but even when i created a folder inside bin and again tried to compile, the path being
C:\Program files\java\jdk\bin\Jprojects\HelloWorld>javac HelloWorld.java
i still get the same error....
Rob Spoor wrote:I highly discourage putting your source files in your JDK's folder or any of its sub folders. Create a dedicated folder for all your development work, with sub folders for each project. For instance, C:\Projects will hold all projects.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:
Sumit Rai wrote: 1. If I directly give path as C:\Jprojects // which is the folder I have created..
It says same " javac not recognised...".
Because your PATH is still not setup correctly.
2. but even when i created a folder inside bin and again tried to compile, the path being
C:\Program files\java\jdk\bin\Jprojects\HelloWorld>javac HelloWorld.java
i still get the same error....
That's because you're still using a folder inside the JDK folder. I clearly said
Rob Spoor wrote:I highly discourage putting your source files in your JDK's folder or any of its sub folders. Create a dedicated folder for all your development work, with sub folders for each project. For instance, C:\Projects will hold all projects.
C:\Program files\java\jdk\bin\Jprojects\HelloWorld>javac HelloWorld.java
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
. . . and every time you want that folder you can writemkdir javaWork
cd javaWork
As for setting your PATH, there are several ways to do it, one of which is in our FAQ.cd javaWork