0

I am new to Java and its my first program in Java, I am trying to run HelloWorldApp program but its giving an error

c:\Program Files (x86)\Java\jdk1.6.0_14\bin>javac HelloWorldApp.java"
HelloWorldApp.java:5: error while writing HelloWorldApp: HelloWorldApp: HelloWorldApp.class (Access is denied)
public class HelloWorldApp(
1 error

I wrote the given code in NotePad and saved that in C:\Program Files (x86)\Java\jdk1.6.0_14\bin

public class HelloWorldApp{

    public static void main(String[] args){

        System.out.println("Hello World");
    }
}
1
  • 3
    Sorry, but why did you decide to place your code inside bin directory? Any special reason for that? Commented Apr 17, 2015 at 12:58

4 Answers 4

4

Put in a folder where administrator rights isn't required. Eg on your desktop. Then open cmd.exe and type cd C:\path\to\file. Finally use the same javac command.

Sign up to request clarification or add additional context in comments.

Comments

2

Run your command prompt with administrative privilege.

3 Comments

It has compiled now but has generated this error: Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp/class Caused by: java.lang.ClassNotFoundException: HelloWorldApp.class at java.net.URLClassLoader$1.run(URLClassLoader.java:200) ..................
@Yasir This is subject for another question which you should ask after searching and reading questions about similar problem like this one: stackoverflow.com/q/22605831/1393766
These all errors are related to access of the location your code is placed. It is recommended to pull your code from bin directory to some other directory like on desktop( or any other where permission is not a problem).
0

The error clearly says access denied. Get admin rights for the java folder or place your class file in a different directory for which you have admin rights and try to run.

Comments

0

You don't have access to folder where You put class file. Move file to another folder where you have proper permission or run that command as administrator.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.