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

Java Local Development Environments Exploring Your IDE Creating Your First Project

Sean Flanagan
Sean Flanagan
33,235 Points

Directory

Hi. I tried moving my version of JDK into the directory but nothing came up. What should I do please?

Thanks.

18 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

If you try to choose this when you add a new JDK in IntelliJ

C:\ProgramData\Oracle\Java\javapath\

Does it work?

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Sean!

Do you mean you installed the Java JDK and it's not in the drop box when you go to choose the JDK during new project creation?

What OS are you running?

We'll get it sorted!

The system variables you need to create a new system variable so you click new and you call this variable JAVA_HOME and the VALUE that the variable needs is where your java jdk is for example my java jdk is in C:\Program Files\Java\jdk1.8.0_51 so then make sure you find your path to the jdk and put that in as the value for the system variable if that does not work just add this to the end of the \bin so it looks like this C:\Program Files\Java\jdk1.8.0_51\bin and then save it and that should work :).

Sean Flanagan
Sean Flanagan
33,235 Points

"The system variables you need to create a new system variable so you click new..." Which menu do I have to select New from?

By the way, I've moved my JDK to my desktop.

you click new in system variables and a window will open up and in the box variable name put JAVA_HOME and for the variable value add your path to the jdk example C:\Users\Alex Stephens\Desktop\jdk1.8.0_51\bin

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Sean,

Are you opening a command prompt when you type java -version? Try typing cmd in the run bar to open a command prompt open.

Let me know what that prompt says.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Can you see if this works:

where javac
Sean Flanagan
Sean Flanagan
33,235 Points

Hi Craig. My OS is Windows 7. My JDK version is 14.1.4. I've got as far as the "Select Home Directory for JDK" dialogue box. This is where I've hit a snag. I'm not sure which directory is the best one to use.

I'd appreciate any advice you have to offer.

Sean :-)

Craig Dennis
Craig Dennis
Treehouse Teacher

Hmmm 14.1 is your version of IntelliJ. Did you do the step where you download and install the Java JDK?

What is your result when you run

java -version
Sean Flanagan
Sean Flanagan
33,235 Points

"Did you do the step where you download and install the Java JDK?" Yes, it's jdk-8u60-windows-i586.

When I run java -version, I just get a Command Prompt. It pops up for less than a second and then vanishes.

Have you tyred setting the system variables in your computer that is pointed to the jdk ?

Sean Flanagan
Sean Flanagan
33,235 Points

Alex Stephens: Hi Alex. Thanks for chiming in. What should the system variables be set to please?

Thanks. :-)

Sean Flanagan
Sean Flanagan
33,235 Points

Okay, from my desktop, I clicked on the Start menu -> Computer -> System Properties -> Advanced System Settings -> Environment Variables -> New (under System Variables). At this point, the New System Variable box pops up. So in "Variable name" I type in JAVA_HOME and in "Variable value", my path?

Craig Dennis
Craig Dennis
Treehouse Teacher

If its not there already I'd suggest reinstalling your Java JDK

Sean Flanagan
Sean Flanagan
33,235 Points

It just says "The selected directory is not a valid home for the JDK".

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Craig. Thanks for your suggestion. Sorry for the delay - this is due to my getting ready to go on holiday (or vacation as you guys Across the Pond call it :-) ) tomorrow.

To answer your question, I called up the Command Prompt. It says:

"C:\Users\user>" and there's a cursor after it where you can type. Do I need to type anything?

Thanks Craig :-)

Craig Dennis
Craig Dennis
Treehouse Teacher

Great! Now run

java -version
Sean Flanagan
Sean Flanagan
33,235 Points

Done. Output:

java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode, sharing)

Thanks for your help so far. :-)

Sean Flanagan
Sean Flanagan
33,235 Points
INFO: Could not find files for the given pattern(s).
Sean Flanagan
Sean Flanagan
33,235 Points
C:\ProgramData\Oracle\Java\javapath\java.exe
Sean Flanagan
Sean Flanagan
33,235 Points

Hi Craig. Thank you and Alex for your help. I got a reply from you but it seems to have disappeared. I opened IntelliJ but it took me to this page with a title bar and menu bar. On the left is a window with Project and a down arrow and beneath that is something called External Libraries. My command prompt is still open. Do I need to type in:

C:\ProgramData\Oracle\Java\javapath\java

?

Thanks.

Craig Dennis
Craig Dennis
Treehouse Teacher

I believe you are all set to go now!

Craig Dennis
Craig Dennis
Treehouse Teacher

I believe you are all set to go now!

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Craig. Thanks for your help. Unfortunately it's still not working. I've got the dialogue box "Select Home Directory for JDK" open but none of the folders will accommodate JDK. Every time I click the blue OK button at the bottom of the dialogue box, I just get a message: "The selected directory is not a valid home for JDK".

Craig Dennis
Craig Dennis
Treehouse Teacher

Sean,

Does this folder exist? C:\Program Files\Java\

The jdk should be in that directory. Choose the JDK folder and choose okay.

Craig Dennis
Craig Dennis
Treehouse Teacher

Sean,

Does this folder exist? C:\Program Files\Java\

The jdk should be in that directory. Choose the JDK folder and choose okay.

Sean Flanagan
Sean Flanagan
33,235 Points

Yes, the folder you refer to exists. I clicked on it and it's let me in. Thank you very much for your help Craig. I very much appreciate what you and Alex have done for me and sorry for all the trouble. :-)