reset password
Author Message
sidguttula
Posts: 16
Posted 12:30 Apr 01, 2016 |

For question 2 on this week's lab, my program is called LAB01P02.java

On the command prompt, I use the javac command to compile my program,  it always gives me an error that says "error writing LAB01P02.class (Access is denied) "
I cannot go any further from this. 

What do I do now? 

aalva190
Posts: 64
Posted 12:32 Apr 01, 2016 |

You probably didnt set up java and jdk as directed in the directions. Maybe

aalva190
Posts: 64
Posted 12:33 Apr 01, 2016 |

Post a picture to have a better view of the error

sidguttula
Posts: 16
Posted 12:38 Apr 01, 2016 |

Can you guys help me on what to do next? 

Attachments:
aalva190
Posts: 64
Posted 12:43 Apr 01, 2016 |

Are you trying to run it inside Java jdk? I dont think thats right. Try to write the code outsidr the jdk. I believe the reason its giving you a acces denied is because ur trying to add files to jdk which you cant becuase thats java. Try to folder put the files there and run it inside there. Dont run it inside java jdk. Hopefully i am right if not wait till Keenan Knaur comes by.

kknaur
Posts: 540
Posted 12:51 Apr 01, 2016 |

You have to set your PATH variable in the Windows Environment Variable (should be in the instructions for installing Java, or you can Google / look for  YouTube video.  Assuming this has been done, you shouldn't put your Java code in the folder where you currently have it.  Windows likes to keep things locked down, so unless you run the command prompt in admin mode, you won't have write access to things in the program files folder.  Store your file on the desktop, in another folder on the C drive or on a flash drive and this should correct the permissions access issue.

sidguttula
Posts: 16
Posted 12:51 Apr 01, 2016 |

So my command from the folder is C;\Program Files\Java\jdk1.8.0_77\bin\javac LAB01P02.java

what should my code outside the jdk be?

aalva190
Posts: 64
Posted 12:56 Apr 01, 2016 |

here, try this. 

First create a folder inside the C Drive computer, thats where Keenan recommended us to put the folder, name it anything.

 

Then paste ur java file inside that folder.

Then on the command prompt go to that folder. 

fin

Finally just go and compile the program make sure use javac filename.java

then run the program using java filename 

to run it you dont need the .java at the end

Hopefully this works

64bitworldftw
Posts: 11
Posted 13:01 Apr 01, 2016 |

Where the LAB01P02.java file is located. You're using the path for JDK, which is where javac is located, but not your java file.

Though, you should set the PATH variable, like Keenan said. It would be much easier when you use command prompt to compile java files instead of going to command prompt finding where javac is at. After you set the PATH variable, then use command prompt and set the path where your LAB01P02.java file is located, then use javac LAB01P02.java.

sidguttula
Posts: 16
Posted 13:10 Apr 01, 2016 |

Thank you so much aalva190! It finally worked, but the result i got was '4'. Not 3.01 like Keenar said.

aalva190
Posts: 64
Posted 13:14 Apr 01, 2016 |

Your welcome, make sure that syntax is actually correct the equation parenthesis might effect things.  also for divisions such as 1/3 is actually 1.0/3.0 and you should be good. 

Glad i could help :)

Aaron