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 trialKevin McFarland
5,122 PointsJava commands in Terminal launches Intellj IDE...
Ever since I installed the Intellij IDE I can't run the Java REPL or any other Java command without the Intellij IDE launching. It's seems to have hi-jacked the class path to the Java VM. Can anyone help?
Thanks,
Kevin
6 Answers
Kevin McFarland
5,122 PointsThank you,
That makes sense... and problem solved!
Craig Dennis
Treehouse TeacherHi Kevin!
Which OS?
You mean
java MyProgram.java
Opens IntelliJ?
Kevin McFarland
5,122 PointsSorry, I guess that's a little vague.
Mac OS X . In the terminal if I type any command related to Java, the Intellij Java IDE launches. Something as simple as... "java -version" will launch the IDE with error about being unable to locate the file or command. I was running the REPL just fine before installing Intellij. Can't figure it out. Don't know how to use the info output from System.getProperty() to trace the problem.
Thanks,
Kevin
Craig Dennis
Treehouse TeacherWhat does
which java
from the terminal return?
Kevin McFarland
5,122 Points/usr/local/bin/java
Craig Dennis
Treehouse TeacherAlright let's check that symbolic link:
ls -la /usr/local/bin/java
Kevin McFarland
5,122 Points-rwxr--r-- 1 kmcfrld staff 2771 Apr 20 15:22 /usr/local/bin/java
Thanks for helping me out on this... I suppose I need to educate myself concerning how this all works. What do you recommend?
Craig Dennis
Treehouse TeacherNo problem man! Sorry this is happening to you.
It is weird that it's not a link to somewhere. Usually there is an -> pointing to where it actually lives...can you do me a favor and see if /usr/bin/java exists
ls -la /usr/bin/java
Console foundations shows off some of these tricks.
Kevin McFarland
5,122 PointsThanks, ls -la /usr/bin/java returns:
lrwxr-xr-x 1 root wheel 74 Oct 23 2014 /usr//bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
Craig Dennis
Treehouse TeacherCool that's the right one...not sure how that happened but let's move the weird one out of the way:
mv /usr/local/bin/java /usr/local/bin/weirdjava
So the way things work usually is much like the ClassPath I discussed in the video. There is a PATH environment variable, and when you type a command it looks in order of those folders, so /usr/local/bin
is coming before /usr/bin
. Because java
is no longer in the local folder (because we renamed it to weirdjava) it should find your next version. When I used the which java
statement it told me what was running when we called java.
Make sense?
If you did want to see your PATH variable you can go:
echo $PATH
Kevin McFarland
5,122 PointsSorry Craig,
Not sure how I've given myself the Best answer tag...