Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error while compiling a program in Java using command prompt  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check this link
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Welcome to JavaRanch
 
sagar karyamapudi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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!
 
Sheriff
Posts: 21330
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sagar karyamapudi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Marshal
Posts: 59108
180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!