GeeCON Prague 2014*
The moose likes Java in General and the fly likes Error while compiling a program in Java using command prompt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Error while compiling a program in Java using command prompt" Watch "Error while compiling a program in Java using command prompt" New topic
Author

Error while compiling a program in Java using command prompt

sagar karyamapudi
Greenhorn

Joined: Jun 21, 2011
Posts: 4
Hii all..
I have just started learning java.
From the above link
http://www.coderanch.com/how-to/java/how-to-create-java-program#downloadSDK ,
I also wrote my first java program, but the problem comes here.
After setting the path and compiling, the class is not being created in the directory called 'src'.
The error is being displayed as:
"MooseGreetings.java:1: error while writing MooseGreetings: MooseGreetings.class <Access is denied>
public class MooseGreeting
^
1 error "

Hope you would help me regarding this, because with getting this small program executed I can't move furthur.

Thanks,
k. sagar
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

check this link
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

And Welcome to JavaRanch
sagar karyamapudi
Greenhorn

Joined: Jun 21, 2011
Posts: 4
I had made the directory under program files. i.e the path c:\Program Files\Java
Is that really the culprit ?
I have given writing access to the directory i.e it is not read-only

Thanks for your reply Seetharaman Venkatasamy

But still the problem persists. Should I change the directory to C. ??

Thanks in advance..
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

sagar karyamapudi wrote: Should I change the directory to C. ??

I dont know about windows7. but in that link Paul said not to keep your java working directory under program files. so please change the location to c drive as you mentioned.
lets give a try!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Windows Vista and Windows 7 have something called User Access Control (UAC). This will ask you each time when you try to make any changes to the Program Files or Windows folder. However, it doesn't work well when called from a command line or another application. And then there is simply an access denied message.

You can turn off UAC, but I suggest you use a different path instead. Not directly in C:, but something like C:\Java or perhaps a completely different drive.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

I think if you run command prompt as an administrator in windows7 (you can do this by right click on cmd and run as administrator) then it should work.
I haven't tried this but I am guessing.


Piyush
sagar karyamapudi
Greenhorn

Joined: Jun 21, 2011
Posts: 4
First of all, thanks to Seetharaman Venkatasamy, Rob Spoor and Piyush Joshi for your replies.

I am using Vista OS.

In order to change the directory of Java from program files to local drive or else or any other drive should I uninstall the whole setup or is there any other way..
Thank you guys, In advance..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39102
    
  23
Suggestion: Open a command prompt and write

or similar
Then
You can now go to your "java" folder just by writing cd java.
sagar karyamapudi
Greenhorn

Joined: Jun 21, 2011
Posts: 4
Thanks to all of you guys..

IT'S DONE..

I have installed the latest version of JDK in the C drive directly, rather than in Program Files.
Now it's working.. Successfully completed MY PROGRAM in java.
Thanks all once again.

Cheers.,
K.Sagar..
 
GeeCON Prague 2014
 
subject: Error while compiling a program in Java using command prompt