spywhere / Javatar

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

Javatar cannot find JDK without `JAVA_HOME` set #55

Closed cinvoke closed 8 years ago

cinvoke commented 9 years ago

Hi, I have tried setting linux to "/usr/lib/jvm" "/usr/lib/jvm/java-8-openjdk-amd64" "

Ive also changed the executable to :
// Executables that Javatar used "java_executables": { "build": "/usr/bin/javac", "run": "/usr/bin/java", "lint": "/usr/bin/javac", "version": "/usr/bin/java", "script": "/usr/bin/jrunscript" },

I'm not sure how else to get Javatar to see JDK. Should I be using a JAVA_HOME envvar?

actual locations: ll /usr/bin/java lrwxrwxrwx 1 root root 22 Aug 28 18:28 /usr/bin/java -> /etc/alternatives/java lrwxrwxrwx 1 root root 23 Oct 19 20:16 /usr/bin/javac -> /etc/alternatives/javac lrwxrwxrwx 1 root root 25 Oct 19 20:16 /usr/bin/javadoc -> /etc/alternatives/javadoc lrwxrwxrwx 1 root root 32 Oct 19 20:16 /usr/bin/javafxpackager -> /etc/alternatives/javafxpackager lrwxrwxrwx 1 root root 23 Oct 19 20:16 /usr/bin/javah -> /etc/alternatives/javah lrwxrwxrwx 1 root root 23 Oct 19 20:16 /usr/bin/javap -> /etc/alternatives/javap lrwxrwxrwx 1 root root 30 Oct 19 20:16 /usr/bin/javapackager -> /etc/alternatives/javapackager lrwxrwxrwx 1 root root 24 Oct 19 19:39 /usr/bin/javaws -> /etc/alternatives/javaws*

ll /usr/lib/jvm/ total 56 lrwxrwxrwx 1 root root 20 Jul 24 01:58 java-1.7.0-openjdk-amd64 -> java-7-openjdk-amd64/ -rw-r--r-- 1 root root 2439 Jul 24 01:58 .java-1.7.0-openjdk-amd64.jinfo lrwxrwxrwx 1 root root 20 Apr 19 2015 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64/ -rw-r--r-- 1 root root 2546 Apr 19 2015 .java-1.8.0-openjdk-amd64.jinfo drwxr-xr-x 5 root root 4096 Oct 19 20:14 java-7-openjdk-amd64/ drwxr-xr-x 5 root root 4096 Oct 19 20:23 java-8-openjdk-amd64/ drwxr-xr-x 8 root root 4096 Oct 19 20:16 java-8-oracle/ -rw-r--r-- 1 root root 2643 Oct 19 20:16 .java-8-oracle.jinfo

Thanks.

spywhere commented 9 years ago

The executable settings must contain only file names. For the JDK installation path, you have to override the jdk_installation settings for Linux in the settings file to make the Javatar search into that directory.

JAVA_HOME detection is not implement yet right now. So, settings the JAVA_HOME variable does not help fix the issue.

cinvoke commented 9 years ago

That makes sense. However, when I point it to a directory that clearly has the jdk installation in it, it still says it cannot find JDK.
For example: My /usr/bin has java, javac, jrunscript

spywhere commented 9 years ago

Could you send me your settings configurations? And may be some logs from the Sublime Text's console.

cinvoke commented 9 years ago

Sure no prob. Sublime log: http://dpaste.com/2QRWQ4J

Sublime conf: http://dpaste.com/26CBRKF

spywhere commented 9 years ago

I didn't see your changes to jdk_installation. Are you sure you give me "your" settings not default settings

cinvoke commented 9 years ago

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

i changed it back because i can reach all the java executables from /usr/bin:

~$ which java /usr/bin/java

settings: "jdk_installation": { "osx": ["/Library/Java/JavaVirtualMachines"], "windows": ["C:\Program Files\Java", "C:\Program Files (x86)\Java"], "linux": ["/usr/bin"] },

// Runtime required files
"java_runtime_files": {
    "runtime": ["rt.jar"]
},

// Executables that Javatar used
"java_executables": {
    "build": "javac",
    "run": "java",
    "lint": "javac",
    "version": "java",
    "script": "jrunscript"
},
cinvoke commented 9 years ago

I also have this, but wasnt sure it needed to be pointed to: http://dpaste.com/1KV65GV

spywhere commented 9 years ago

The JDK installation is correct from the file tree you give me. That is left with the Javatar cannot find that JDK. Could you try using the path /usr/lib/jvm/ instead of /usr/bin for the Linux key?

If this works, I think I have an idea of how this can happens.

cinvoke commented 9 years ago

Nope. same jdk not found.
console: http://dpaste.com/3FJ6VJH

/usr/lib/jvm > http://dpaste.com/0CJCW3F

spywhere commented 9 years ago

Try running these commands (one by one) in the Sublime Text's console...

import Javatar
th = Javatar.threads.jdk_manager.JDKDetectorThread()
th.is_jdk_path("<<Your JDK Path Here>>")

Try change the JDK path (in the command) to point to the bin directory of your JDK. This should returns True.

If it returns True, run the java -version in the terminal and send me your JDK path that works and also a version from the terminal.

cinvoke commented 9 years ago

interesting.. It sees everything in /usr/bin but my jdk lib is definitely in /usr/lib/jvm...

import Javatar th = Javatar.threads.jdk_manager.JDKDetectorThread() th.is_jdk_path("/usr/lib/jvm/java-8-openjdk-amd64/bin") False th.is_jdk_path("/usr/lib/jvm/java-8-openjdk-amd64/") False th.is_jdk_path("/usr/lib/jvm/") False th.is_jdk_path("/usr/lib/jvm") False th.is_jdk_path("/usr/bin") True

spywhere commented 9 years ago

Could you check the symlink of each executable file in the /usr/bin? I think it might point to different JDKs.

cinvoke commented 9 years ago

That was it: /usr/bin$ ll java lrwxrwxrwx 1 root root 22 Aug 28 18:28 java -> /etc/alternatives/java lrwxrwxrwx 1 root root 23 Oct 19 20:16 javac -> /etc/alternatives/javac lrwxrwxrwx 1 root root 25 Oct 19 20:16 javadoc -> /etc/alternatives/javadoc lrwxrwxrwx 1 root root 32 Oct 19 20:16 javafxpackager -> /etc/alternatives/javafxpackager lrwxrwxrwx 1 root root 23 Oct 19 20:16 javah -> /etc/alternatives/javah lrwxrwxrwx 1 root root 23 Oct 19 20:16 javap -> /etc/alternatives/javap lrwxrwxrwx 1 root root 30 Oct 19 20:16 javapackager -> /etc/alternatives/javapackager lrwxrwxrwx 1 root root 24 Oct 19 19:39 javaws -> /etc/alternatives/javaws*

Then i changed the linux key to point to /etc/alternatives. Still same error.

spywhere commented 9 years ago

At minimum, JDK should conform with the following rules...

If one of the rule is not match, the JDK will considered invalid.

cinvoke commented 9 years ago

looks like its java_version match. match is returning in jdk_manager.py but no groups nor lastIndex.

Regex: "(\d+.\d+.\d+)_?([0-9a-zA-Z]+)?" I tried running the regex from java_version_match key on the text i get when i run java -version in gskinner... this regex looks correct to me.

Console: [Javatar] Error! JDK Detection Error: Traceback (most recent call last): File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/threads/jdk_manager.py", line 239, in run jdks = self.verify_jdks() File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/threads/jdk_manager.py", line 204, in verify_jdks default = self.get_jdk_version() File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/threads/jdk_manager.py", line 41, in get_jdk_version path, exes["version"] File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/threads/jdk_manager.py", line 55, in get_jdk_version if match.lastindex > 0: TypeError: unorderable types: NoneType() > int()

Traceback (most recent call last): File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/threads/jdk_manager.py", line 239, in run jdks = self.verify_jdks() File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/threads/jdk_manager.py", line 204, in verify_jdks default = self.get_jdk_version() File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/threads/jdk_manager.py", line 41, in get_jdk_version path, exes["version"] File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/threads/jdk_manager.py", line 55, in get_jdk_version if match.lastindex > 0: TypeError: unorderable types: NoneType() > int()

cinvoke commented 9 years ago

actually , that was from me hardcoding the java version trying to force the java_version_match key... i put that back ;)

so now i get: [Javatar] v2.0.0-prebeta.3 [Javatar] Snippet Class.javatar-snippet loaded [Javatar] Snippet Enumerator.javatar-snippet loaded [Javatar] Snippet Interface.javatar-snippet loaded [Javatar] No JDK found error: Javatar cannot find JDK installed on your computer.

Please install or settings the location of installed JDK. [Javatar] Startup Time: 0.08s [Javatar] Error! Error while sending usages data: Traceback (most recent call last): File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/core/usages.py", line 31, in send_usages on_complete=self.on_usages_sent File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/utils/downloader.py", line 26, in request url += "?" + urllib.parse.urlencode(params) AttributeError: 'module' object has no attribute 'parse'

Traceback (most recent call last): File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/core/usages.py", line 31, in send_usages on_complete=self.on_usages_sent File "/home/cinvoke/.config/sublime-text-3/Packages/Javatar/utils/downloader.py", line 26, in request url += "?" + urllib.parse.urlencode(params) AttributeError: 'module' object has no attribute 'parse'

[Javatar] Javatar extension plugin "JavatarAutoComplete" has been loaded [Javatar] Javatar extension plugin "JavatarMenu" has been loaded [Javatar] Javatar extension plugin "JavatarProjectRestoration" has been loaded

cinvoke commented 9 years ago

I just purged all java and symlinks until no java jre nor jdk existed. then i installed open jre 7 and jdk 7. /usr/bin points the /etc/alternatives , where each java binary is linked to /usr/lib/jvm/java-7-openjdk-amd64/bin/

spywhere commented 9 years ago

The AttributeError: 'module' object has no attribute 'parse' error is just a network module error which is not a part of the JDK issue.

The RegEx will match both ? statement, this should give empty string instead of None since the group is valid.

cinvoke commented 9 years ago

im not sure if there is anything i can do from a config stance at this point. Ive tried everything i can find. All my paths are correct now i believe. I only have one version of Java installed. Have you seen many issues with openjdk7?

spywhere commented 9 years ago

No, I don't see many (reported) issues with OpenJDK. Most of the issue about JDK is just misconfigure the JDK paths.

I still don't have any clue of how it's happen if the JDK is valid. So, the only cause that might have is a detection sequence which lead to the following questions.

  1. Could you send me the following things?
    • Path to each installed JDK (make sure the executable files is all exists)
    • Version informations from running the java -version command on each JDK
  2. Could you send me the full console log when Sublime Text starts?
  3. Could you try running Javatar with a fresh, new, Sublime Text with only Package Control and Javatar?
spywhere commented 8 years ago

After investigated with a help on #65 This issue should be solved in a next version. I'll update this issue and close it once I release a new version.

spywhere commented 8 years ago

Javatar v2.0.0-prebeta.6 is up. This release should fix JDK detection issue now. You should be able to use a new release within 6 hours :)

quazi-irfan commented 8 years ago

The error is gone, and it looks like Javatar is detecting JDK now. I've installed Java 8 on my system.

Here is the Sublime log.

DPI scale: 1.25
startup, version: 3114 windows x64 channel: stable
executable: /C/Program Files/Sublime Text 3/sublime_text.exe
working dir: /C/Program Files/Sublime Text 3
packages path: /C/Users/iamcr/AppData/Roaming/Sublime Text 3/Packages
state path: /C/Users/iamcr/AppData/Roaming/Sublime Text 3/Local
zip path: /C/Program Files/Sublime Text 3/Packages
zip path: /C/Users/iamcr/AppData/Roaming/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.0847788
startup time: 0.122779
first paint time: 0.124779
first paint time: 0.124779
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.02-bz2
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin Javatar.Javatar
plugins loaded
[Javatar] v2.0.0-prebeta.6
[Javatar] Snippet Class.javatar-snippet loaded
[Javatar] Snippet Enumerator.javatar-snippet loaded
[Javatar] Snippet Interface.javatar-snippet loaded
[Javatar] Use default JDK [JDK1.8.0u92]
Package Control: Skipping automatic upgrade, last run at 2016-06-27 16:26:34, next run at 2016-06-27 17:26:34 or after

Thank you for the quick fix. :)