Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access is denied error message

 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Angus Comber
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15438
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:\.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic