I created two java files: Pizza.Java
and PizzaOrder.Java
.
I tried compiling my code using javac in the command prompt like this:
javac pizzaorder.java
I am getting access is denied error:
C:\Users\Meutex>cd\
C:\>cd "Program Files\Java\jdk1.7.0\bin"
C:\Program Files\Java\jdk1.7.0\bin>javac PizzaOrder.java
PizzaOrder.java:23: error: cannot find symbol
Pizza order = new Pizza ();
^
symbol: class Pizza
location: class PizzaOrder
PizzaOrder.java:23: error: cannot find symbol
Pizza order = new Pizza ();
^
symbol: class Pizza
location: class PizzaOrder
2 errors
C:\Program Files\Java\jdk1.7.0\bin>javac Pizza.java
Pizza.java:11: error: error while writing Pizza: Pizza.class (Access is denied)
public class Pizza {
^
1 error
C:\Program Files\Java\jdk1.7.0\bin>javac Pizza.java
What am I doing to cause this error?
It means that javac.exe executable file, which exists in bin directory of JDK installation folder is not added to PATH environment variable. You need to add JAVA_HOME/bin folder in your machine's PATH to solve this error. You cannot compile and run Java program until your add Java into your system's PATH variable.
It appears that you're trying to put your source files in the system C:\Program Fiels\Java\jdk1.7.0\bin
directory. Try making your own directory for your source files (under your own home directory), instead of putting them in the system path. You probably don't have permissions to write to that directory (but I'm not sure how you got your source files there).
The Access Denied error is most likely due to the fact that you're trying to compile this program within the jdk directory, which is inside \Program Files
, which is NOT universally writeable by users. You should be doing your coding elsewhere (perhaps in your My Documents
directory, or at least somewhere you've got write permissions).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With