Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App (2014) Getting Started with Android Setting Up an Android Development Environment for Windows

Haziq Nordin
PLUS
Haziq Nordin
Courses Plus Student 1,644 Points

I downloaded and installed Java, but when I type in javac -version in the command prompt, it says I don't have it.

Hello! I downloaded and installed Java, but when I type in javac -version in the command prompt, it says I don't have it.

However, if I go to "Programs and Features" and look at my list of installed programs, I have so many versions of Java installed. I have Java 7 Update 75 (64-bit), Java 8 Update 45, Java 8 Update (64-bit), Java SE Devleopment Kit 7 Update 67 (64-bit), Java SE Development Kit 7 Update 75 (64-bit), Java SE Development Kit 8 Update 45 (64-bit).

What is going on? Do I have Java? And do I really need all those versions of Java installed on my computer or can I delete some of them?

2 Answers

AFTER SETTING YOUR SYSTEM VARIABLE TO JAVA_HOME YOU NEED TO DO THIS FOR IT WORK ON YOUR COMMAND PROMPT:

After setting the JAVA_HOME system variable you need to also set the path so you can use javac from the command prompt:

After setting the JAVA_HOME system variable:

  1. Inside System Variables find "Path" and click "Edit"
  2. At the end of the Path add this line: ";%JAVA_HOME%\bin" (without the double quotes)
  3. Now click "Ok" and exit out of your command prompt window (If it's still open)
  4. now try "javac -version" and it should work
  5. You can also check your java version, JRE build version, and Java Server VM build by typing "java -version"

Where you able to set the JAVA_HOME path? Once you install the Java SDK, the system doesn't automatically recognize it as a path, you need to specify it.

On Windows, Click on the Windows Button > Click on My Computer > Properties > then Click on Advance system Settings, a pop up dialog box will appear, then > click on Environment Variables. At this point you are given two displays 1. On User Variables the other On System variables, under the System Area, Click on ADD NEW, then set Variable name as JAVA_HOME and for the Variable value (go to Computer, C:/program files/java/jdk7.... then copy the url of the folder and paste, then click ok.

The other recommendation, is to see on the System Variables dialog, if PATH is availalbe, then paste then append the URL of the JAVA to the end of the list starting with ; and click ok

So I did this cuz nothing else worked. " The other recommendation, is to see on the System Variables dialog, if PATH is availalbe, then paste then append the URL of the JAVA to the end of the list starting with ; and click ok".

Command Prompt: "javac -version"

Now it says this in the Command Prompt: "could not find or load main class com.sun.tools.javac.MAIN"

Haven't beem able to get my java working for hours. Now uninstalled all my javas and installed JDK 7. Wrote the variables values and names and nothing worked. So tried putting java URL at end of pass like said above. So am I missing something or what happened.