I'm using command prompt on Windows 7 to compile and run my java programs.
I myself is the user of this machine and have logged in using a profile which has administrator rights, besides that I've also changed the properties of my 'C' drive to make read and write allowed for others.
But still while compiling a source code I'm getting 'Access is denied' message.
Below is the command.
But it works if I change it to this :
I guess the first command entered is not wrong in syntax as I'm getting authority related message upon execution.
Another question related to the above problem is that
when I write javac -help, it shows me
1. -classpath <path> -- Specify where to find user class files and annotation processors
2. -d <directory> -- Specify where to place generated class files.
Does -d option only take directory name like c , d etc. or a full path where I want my .class file e.g. C:\Jprog as -classpath shows path?
If I give just directory name then I get following message :
If I give full path name, the message is different.
When you see:
-classpath <path> -- Specify where to find user class files and annotation processors
What do you think <path> designates?
Do you think it could possibly mean you substitute YOUR path with <path>???
Actually had had a quick search online and couldn't find a link to explain. But <> syntax is commonly used to denote a placeholder. ie if your classpath should be: C:\MyClasspath you would use -classpath C:\MyClasspath. You don't actually type the angle brackets.
But before doing any of this why are you using classpath. Do you know what the -classpath argument is used for? I don't think you do. Don't use it until you need it. That will be later on in your programming career when you will be introduced to the concept.
I assume you are starting out in Java and only writing your code in a single file? If correct you DON'T need to worry about classpath.
You were getting access denied because javac could not access a file named <C:\Jsource>. It might have succeeded however in accessing C:\Jsource. But as I said you don't need classpath yet.
On WIndows 7, some system directories are protected: you are normally not allowed to write files in those directories. One of those is C:\, the root directory of the harddisk. That is why you get an "Access is denied" message: you are not allowed to write files in C:\.