wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Access is denied error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Access is denied error message" Watch "Access is denied error message" New topic
Author

Access is denied error message

pramod talekar
Ranch Hand

Joined: Apr 26, 2010
Posts: 323

Hello,

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.

Please advise.


Thanks,
Pramod
pramod talekar
Ranch Hand

Joined: Apr 26, 2010
Posts: 323

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.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42600
    
  65
Either of these should work:

C:\> javac Jsource\convert.java

C:\Jsource> javac convert.java

The angle brackets are not meant to be typed, they just indicate where a parameter should go.


Ping & DNS - my free Android networking tools app
Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
Well, you made me smile

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.

Angus
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14342
    
  22

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:\.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access is denied error message