spywhere / Javatar

Java Development Plugin for Sublime Text 3
https://javatar.readthedocs.org/
Other
170 stars 20 forks source link

Automatically detect JDK from JAVA_HOME environment in addition to the default one #53

Closed ghost closed 8 years ago

ghost commented 9 years ago

My configuration:

I have java installed at /opt/jdk/jdk1.8.0_05/ JAVA_HOME is set to: /opt/jdk/jdk1.8.0_05/ /usr/bin/javac points to: /opt/jdk/jdk1.8.0_05/bin/javac /usr/bin/java points to: /opt/jdk/jdk1.8.0_05/java PATH is set to: /usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/jdk/jdk1.8.0_05//bin

When I start sublime, I get the message:

"Javatar cannot find JDK installed on your computer. Please install or settings the location of installed JDK".

Since I have JAVA_HOME set and have set JAVA_HOME as part of my path, I expected Javatar to automatically configure my JVM by convention.

spywhere commented 9 years ago

Just add /opt/jdk/ to linux key under jdk_installation in your settings and restart Sublime Text. Javatar should detect it correctly this time.

Also notice that your PATH variable contains two consecutive slashes.

ghost commented 9 years ago

@spywhere Thank you, I have found:

Within: ~/.config/sublime-text-3/Packages/Javatar/Javatar.sublime-settings

Line: "linux": ["/usr/jdk"]

Should this sort of thing be automatically resolved from a JAVA_HOME variable as part of the JDK detection process?

spywhere commented 9 years ago

(This was too late to reply since you already figured out before I post it) Each plugin in Sublime Text should have their respective settings file in which use to configure how the plugin is work. So in this case, "Settings" is mean Javatar's user settings file which located in many places in Sublime Text such as Command Palette (by typing Javatar Settings) or Menu system (Preferences > Package Settings > Javatar > Settings - User).

Sure, Javatar can automatically set the settings for you but this might conflict the concept of what settings file are used. The possible way I can implement this for you is include the JAVA_HOME in the detection (not in the settings file) so when the default detection is failed, this will get detect instead.

ghost commented 9 years ago

Thank you @spywhere This would be a great addition. JAVA_HOME is used as a way of resolving the JDK for other tools in the Java development chain such as Apache Tomcat and it would be very convenient if Javatar was consistent with this.

spywhere commented 9 years ago

I also missing the fact that Java have JAVA_HOME when I implemented the JDK detection. So that's why this problem happen to you. However, this will be add to a new version for sure.

spywhere commented 8 years ago

This was implemented in Javatar v.2.0.0-prebeta.4. I'll close the issue now.

PS. Strange that I didn't update this issue since it was implemented.