1

I dad left Java since so long as a result now it happens that sometimes I forget the simple things and used to behave like a Stupid.

To run a Simple Java program say "Hello World" written in Notepad what do I have to Do?

I know the commands javac "Filename.java" and java "Filename" respectively to run it from the Command prompt.

But When I try to do that I got this message:

"javac is not recognized as an internal or external command, operable program or batch file."

and I could not Complie the file.

I hava little idea that we need to do some stuffs like setting the classpath or perhaps the path evnironment variables but it was exactly that I don't remember.

Can anybody please help me?

Thanks, david

4
  • Get a decent IDE. IntelliJ is great and has a free community edition. Commented Nov 12, 2010 at 6:47
  • 1
    youtube.com/watch?v=eQ-tBQYjUDc Commented Nov 12, 2010 at 7:32
  • @org.life.java: Do you have a YouTube account. If yes, please comment this video that the class name should start with a capital letter. Otherwise, life would be terrible for us. Commented Nov 12, 2010 at 7:41
  • 1
    @Adeel I haven't watched full video :) and btw I think i will need to sign up for that :) Commented Nov 12, 2010 at 7:46

6 Answers 6

5
  1. Add a JAVA_HOME env variable to point to the jdk installation directory
  2. To your PATH env variable, add %JAVA_HOME%\bin
  3. Add a CLASSPATH env variable to point to %JAVA_HOME%\lib.
  4. remember to open a new console window and try running javac and java - everything should be fine now.
Sign up to request clarification or add additional context in comments.

2 Comments

for the CLASSPATH env variable, is it O.K. if I give upto "%JAVA_HOME%\lib" or I have to add the rt.jar file also at the end?
it's fine to just indicate until the directory if you're using jdk >= 1.6, otherwise you'll need to indicate the JAR/ZIP/.class files.
2

1) create JAVA_HOME environmental variable set value to java home directory

e.g. c:\program files\java\jdk1.5;

1) set PATH in environmental variable to your java bin directory

e.g. %JAVA_HOME%\bin

and to check classpath is set correctly run javac command on cmd

and this link will help to create and run simple java application java tutorial

1 Comment

CLASSPATH should NOT point to the bin folder. it should point to the folder containing the JDK jar files! your suggestion won't work.
2

this might be usefull budddy http://www.apl.jhu.edu/~hall/java/beginner/settingup.html

Comments

1

You need the JDK to be able to run javac.

1 Comment

I know it my friend and I had already installed the jdk, I just want to know about some sort of things done with the environment variables
1

I suggest you first start coding in eclipse, it provides all the environment set up for you. Once you get good with coding, you can try command prompt compiling and running. That way, you will be confident with language first and then go into the nitty-gritties of the environment and set up.

Comments

1

Its better to use any java IDE either eclipse or netBeans Download Link But in case if you like to go through Command prompt method, then u need to set the paths. (These are the variables for your OS, that used to know where your commands e.g. java or javac etc are located). Hope from other answers you set the paths.

Good luck

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.