Java – How to install JDK


I have eclipse and I can test run java apps but I am not sure how to compile them. I read that I should type javac -version into my cmd.exe and see if it is recognized. It is not. So I went to sun's website and downloaded/installed JDK v6. Yet it still says 'javac' is an unrecognized command. What am I doing wrong?


OK after reading some replies it seems like what I am trying to do is create a .jar file that can be ran on another computer (with the runtime). However I am having trouble figuring out how to do that. This might be because I am using Flex Builder(eclipse), but I added the ability to create java projects as well.


OK I do not want to make a JAR file, I am not trying to archive it…the whole point of making a program is to send it to users so they can use the program…THAT is what I am trying to do…why is this so hard?

Best Solution

To setup Eclipse to use the JDK you must follow these steps.

1.Download the JDK

First you have to download the JDK from Suns site. (Make sure you download one of them that has the JDK)

2.Install JDK

Install it and it will save some files to your hard drive. On a Windows machine this could be in c:\program files\java\jdk(version number)

3.Eclipse Preferences

Go to the Eclipse Preferences -> Java -> Installed JREs

4.Add the JDK

Click Add JRE and you only need to located the Home Directory. Click Browse... and go to where the JDK is installed on your system. The other fields will be populated for you after you locate the home directory.

5.You're done

Click Okay. If you want that JDK to be the default then put a Check Mark next to it in the Installed JRE's list.