spywhere / Javatar

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

Error : Javatar cannot find JDK installed on your computer. #65

Closed quazi-irfan closed 8 years ago

quazi-irfan commented 8 years ago

At every startup I get the following error from Javatar "Javatar cannot find JDK installed on your computer".

But, I've updated the java installation location at Peference > Package Settings > Javatar > "Settings - Default",

From: "windows": ["C:\\Program Files\\Java", "C:\\Program Files (x86)\\Java"], To: "windows": ["C:\\Programs\\Java"],

On my system the java binaries are located at, C:\Programs\Java\jdk1.7.0_80\bin And my JAVA_HOME is set to, C:\Programs\Java

So, why can't Javatar find JDK on my system?

This the Sublime log after startup,

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.0680734
startup time: 0.0990734
first paint time: 0.0990734
first paint time: 0.0990734
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 Javatar.Javatar
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
plugins loaded
[Javatar] v2.0.0-prebeta.5
[Javatar] Snippet Class.javatar-snippet loaded
[Javatar] Snippet Enumerator.javatar-snippet loaded
[Javatar] Snippet Interface.javatar-snippet loaded
Package Control: Skipping automatic upgrade, last run at 2016-06-24 23:15:47, next run at 2016-06-25 00:15:47 or after
[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: 4.47s
[Javatar] Javatar extension plugin "JavatarMenu" has been loaded
[Javatar] Javatar extension plugin "JavatarProjectRestoration" has been loaded

And this it the Javatar Action History Report,

## Javatar Report
### System Informations
* Javatar Version: `2.0.0-prebeta.5`
* Sublime Version: `3114`
* Package Path: `C:\Users\iamcr\AppData\Roaming\Sublime Text 3\Packages`
* Sublime Channel: `stable`
* Is Debug Mode: `False`
* Platform: `windows`
* As Packages: `True`
* Package Control: `True`
* Architecture: `x64`
* Javatar's Parent Folder: `Javatar`
* Is Project: `False`
* Is File: `True`
* Is Java: `False`

### Action List
1. Reset all snippets
2. Startup
3. Load snippets
4. Analyse snippet [file=Packages/Javatar/snippets/Class.javatar-snippet]
5. Javatar snippet Class loaded [file=Packages/Javatar/snippets/Class.javatar-snippet]
6. Analyse snippet [file=Packages/Javatar/snippets/Enumerator.javatar-snippet]
7. Javatar snippet Enumerator loaded [file=Packages/Javatar/snippets/Enumerator.javatar-snippet]
8. Analyse snippet [file=Packages/Javatar/snippets/Interface.javatar-snippet]
9. Javatar snippet Interface loaded [file=Packages/Javatar/snippets/Interface.javatar-snippet]
10. Ready within 4.47s
11. Load plugins
12. Select item ['Actions History', 'Generate a report on Javatar actions history'] [from_sublime=True]
spywhere commented 8 years ago

Please continue the discussion on #55 since I still need more information in order to solve this issue. And you can also find a relevant information and some diagnostic solutions there.

quazi-irfan commented 8 years ago

Since the other conversation is already cluttered, I am adding my information on this thread,

I am running on Windows 10 64bit, and I have only one java installed on my system. The path is set as follows,

C:\Users\iamcr>java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

C:\Users\iamcr>where java
C:\Windows\System32\java.exe
C:\Programs\Java\jdk1.7.0_80\bin\java.exe

C:\Users\iamcr>where javac
C:\Programs\Java\jdk1.7.0_80\bin\javac.exe

I've also tried reinstalling Sublime Text 3. I am downloading Javatar zip from github for manual installation.

Do I have to have Package Control installed on Sublime?

Also, Preference > Package Settings > Javatar > Settings - Default shows me the following settings file,

{
    // Per-project settings can be set in .sublime-project file

    //////////////////////
    // Javatar Settings //
    //////////////////////

    // Enable debug messages and some tweaks for debugging Javatar
    "debug_mode": false,

    // Automatically send statistics and usages informations
    "send_stats_and_usages": true,

    // Log all the Javatar actions via Action History
    //     Enable this will helps developer solve the error issues
    "enable_action_history": true,

    // Default delay before hide a status text (in milliseconds)
    //     Must more than 100 milliseconds
    "status_delay": 5000,

    // Default delay before cycle to another status text (in milliseconds)
    //     Must more than 100 milliseconds
    "status_cycle_delay": 1000,

    // Maximum text size when show a scrolling status text
    //     Any scroll-messages longer than this value will be scrolled
    "status_scrolling_size": 50,

    // Show package path in status bar
    "show_package_path": true,

    /////////////////////
    // Global Settings //
    /////////////////////

    // Initial directory for finding dependencies
    "dependencies_path": "%project_dirs_prefix%",

    // Dependencies download location
    "dependencies_download_location": "%project_dirs_prefix%%sep%jar",

    // Javatar cache file location
    "cache_file_location": "%project_dirs_prefix%",

    // Maximum duration until cache expire
    //     Expired cache will have to rebuild all cache once more
    //
    // Format:
    //     d: day
    //     h: hour
    //     m: minute
    //     s: second
    //
    //     Examples:
    //         "1d2h" is 1 day and 2 hours
    //         "6h30m2s" is 6 hours, 30 minutes and 2 seconds
    "cache_valid_duration": "1h",

    // Show hidden files and directories for browsing dependencies
    "show_hidden_files_and_directories": false,

    //////////////////////////////
    // Project Data Restoration //
    //////////////////////////////

    // Allow Javatar to store project data for restoration
    "allow_project_restoration": false,

    // Time interval to update project data for restoration (in milliseconds)
    "project_update_interval": 60000,

    ///////////////////
    // Java Settings //
    ///////////////////

    // JDK installation path
    //     This should contains "jdk1.<major>.0_<minor>" folder or similar
    //     Javatar will use this path to detect your JDK installations and
    //         let's you select version you want to use
    //     Name should be your os name that get from sublime.platform() while
    //         value is a list of JDK installation path
    //     Javatar will use current JDK that you are using, otherwise it will
    //         use latest version you have
    //
    // References:
    //     http://docs.oracle.com/javase/8/docs/technotes/guides/install/index.html
    "jdk_installation": {
        "osx": ["/Library/Java/JavaVirtualMachines"],
        "windows": ["C:\\Programs\\Java"],
        "linux": ["/usr/jdk"]
    },

    // 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"
    },

    // Package exclusions when search for classes
    "java_exclude_packages": [
        "com.sun.",
        "sun."
    ],

    ////////////////////////////
    // Run and Build Settings //
    ////////////////////////////

    // Enable automatic save before build
    "automatic_save": false,

    // Enable automatic build before run
    "automatic_build": true,

    // Always ask if there are more than one main class before run
    //    Disable will automatically run based on a current file
    "always_ask_to_run": false,

    // Always build the file whether it has changed or not
    //    Disable will build based on the file changes
    "always_rebuild": false,

    // Program arguments to pass to the main executed on the "run" command
    "program_arguments": "",

    // Additional arguments to pass to the "build" command
    "build_arguments": "-Xlint:all",

    // Additional arguments to pass to the linter
    "linter_arguments": "-Xlint:all",

    // Run the program on the first (AppKit) thread (OS X Only)
    "always_run_on_first_thread": false,

    // Location to run "run" command
    "run_location": "%project_dirs_prefix%",

    // Location to run "build" command
    "build_location": "%project_dirs_prefix%",

    // Build output (class files) location
    //    Specified here and Javatar will create target path and reference
    //        by -d flag in build_command
    //    In this case, "%project_directory%/bin"
    "build_output_location": "%project_dirs_prefix%%sep%bin",

    // Number of builder threads
    //    Source files will be distributed equally to all builders
    //    Increase this value can helps building done faster but also use more
    //        performances
    "builder_threads": 1,

    // Number of files to build in each builder
    //    Each builder will pass the specified amount of source files
    //        (from this value) to the build command
    //    Proper set this value can helps distributed the load of each build
    //        process
    //    Set a value lower than 1 will build all files at once
    "parallel_builds": 0,

    // Build log view creation delay (in second)
    //    Increase this value can helps prevent double view from showing but
    //        also freeze computer for a specified time
    "build_log_delay": 0.05,

    // Show a build log in specified group and index
    //    This list prioritize from top to bottom
    //    Specified a number or a list of one number, will move the build logs
    //        to target group
    //    Specified a list of two numbers will move the build logs to target
    //        group and target index
    //    If specified target group is not found, the next group index is used.
    //        Otherwise, the build logs will show on current group instead
    //    If specified target index is not found, the build logs will show on
    //        target group as a new view
    //    If both target group and index is not found, the build logs will show
    //        on current group instead
    //    All groups and indices are zero-based
    //    Run -- window.run_command("javatar_view") -- in console to show view
    //        group and index
    "build_log_target_group": [],

    // Show running console in specified group and index
    //     Same format as build_log_target_group
    "output_console_target_group": [],

    // Amount from bottom to snap into autoscrolling area
    // Increase this number if autoscroll is not working properly
    "autoscroll_snap_range": 1,

    // Always scroll view to bottom in output window
    "autoscroll_to_bottom": true,

    // Refresh rate for Javatar shell (in second)
    //    Increase this value can helps shell output to print more smoothly but it's also affect the system performances
    "shell_refresh_interval": 0.01,

    // The encoding to handle input/output of the invoked process
    //    Using the same format as str.encode() in Python 3 used
    "encoding": "UTF-8",

    // Error handler on output encoding
    //    ignore = Remove all invalid encoding character
    //    replace = Replace all invalid encoding character with "?" symbol
    // Change this value without knowing what you're doing is not a good idea
    "encoding_handle": "replace",

    //////////////////////////////////
    // Javatar Validations Settings //
    //////////////////////////////////

    // Java file extensions
    "java_extensions": [".java"],

    // Java source code validation using scope selector
    "java_source_selector": "source.java",

    // Java version matching using RegEx (get from java -version)
    "java_version_match": "(\\d+.\\d+.\\d+)_?([0-9a-zA-Z]+)?",

    // Class declaration name selector (Use in structure parsing)
    "class_declaration_name_selector": ">ClassDeclaration>Identifier",

    // Class declaration and its members filtered selector (Use in structure parsing)
    "class_members_filter_selector": ">ClassDeclaration>[Identifier=%s]",

    // Class constructors selector (Use in structure parsing)
    "class_constructors_selector": ">ConstructorDeclaration",

    // Class constructors selector (Use in structure parsing)
    "class_constructor_name_selector": ">ConstructorDeclaration>Identifier",

    // Class methods selector (Use in structure parsing)
    "class_methods_selector": ">MethodDeclaration>MethodHeader",

    // Class method return type selector (Use in structure parsing)
    "class_method_type_selector": ">MethodDeclaration>MethodHeader>Type",

    // Class method name selector (Use in structure parsing)
    "class_method_name_selector": ">MethodDeclaration>MethodHeader>Identifier",

    // Constructor parameter selector (Use in structure parsing)
    "parameter_selector": ">FormalParameters>FormalParameterList>FormalParameter|>FormalParameters>FormalParameterList>LastFormalParameter",

    // Constructor parameter type selector (Use in structure parsing)
    "parameter_type_selector": ">Type",

    // Constructor parameter name selector (Use in structure parsing)
    "parameter_name_selector": ">VariableDeclaratorId",

    // Class fields selector (Use in structure parsing)
    "class_fields_selector": ">FieldDeclaration",

    // Class field type selector (Use in structure parsing)
    "class_field_type_selector": ">FieldDeclaration>Type",

    // Class field name selector (Use in structure parsing)
    "class_field_name_selector": ">FieldDeclaration>VariableDeclarators>VariableDeclarator>VariableDeclaratorId",

    // Types and classes selector (Use in structure parsing)
    "type_selectors": "@VariableType|@StaticClassOrInterfaceType|@CatchType",

    // Declarations with children selector (Use in structure parsing)
    "declarations_selector": "@PackageDeclaration|>ImportDeclaration>|>ImportDeclaration",

    // Package declaration selector (Use in structure parsing)
    "package_declaration_selector": "@PackageDeclaration",

    // Import declaration selector (Use in structure parsing)
    "import_declaration_selector": "@ImportDeclaration",

    // Package name in import declaration selector (Use in structure parsing)
    "import_declaration_package_selector": ">ImportDeclaration>QualifiedName",

    // Class path validation using RegEx
    "class_path_match": "^(([a-zA-Z_\\-$][a-zA-Z\\d_\\-$]*\\.)*)([a-zA-Z_$][a-zA-Z\\d_$]*)$",

    // Class path (with inheritances) validation using RegEx
    "special_class_path_match": "^([a-zA-Z_\\-$][a-zA-Z\\d_\\-$]*\\.)*[a-zA-Z_$][a-zA-Z\\d_$]*([<:]([a-zA-Z_$][a-zA-Z\\d_$]*)(,[a-zA-Z_$][a-zA-Z\\d_$]*)*)*$",

    // Package path validation using RegEx
    "package_path_match": "^([a-zA-Z_\\-$][a-zA-Z\\\\d_\\-$]*)(\\.[a-zA-Z_\\-$][a-zA-Z\\\\d_\\-$]*)*$"
}

Also, I didn't understand the following this you said,

When run the Java script which show java.home should returns the home directory of the executable that used to run the script

How do I check what java.home holds?

Also, I ran the following code snippet,

>>> import Javatar
>>> th = Javatar.threads.jdk_manager.JDKDetectorThread(
>>> th.is_jdk_path("C:\Programs\Java\jdk1.7.0_80\\bin")
True
>>> th.is_jdk_path("C:\Programs\Java")
False

I hope it helps narrowing down the problem...

spywhere commented 8 years ago

Hmm... feels like it java.home problems... could you try a v2.0.0-PreBeta.3? If that's worked then I think I know what the problem is...

quazi-irfan commented 8 years ago

I just tried with 2.0.0-PreBeta 3 and the issue is still there. 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.10106
startup time: 0.13806
first paint time: 0.13906
first paint time: 0.13906
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.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: 1.04s
[Javatar] Javatar extension plugin "JavatarMenu" has been loaded
[Javatar] Javatar extension plugin "JavatarProjectRestoration" has been loaded
Package Control: Skipping automatic upgrade, last run at 2016-06-26 09:21:44, next run at 2016-06-26 10:21:44 or after

But it finds the JDK when I try Javatar v2.0.0 Prebeta 1. But it shouldn't say it found JDK 8, because I have only JDK 7 installed.

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.0713937
startup time: 0.103394
first paint time: 0.105394
first paint time: 0.105394
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.1
[Javatar] Snippet Class.javatar-snippet loaded
[Javatar] Snippet Enumerator.javatar-snippet loaded
[Javatar] Snippet Interface.javatar-snippet loaded
[Javatar] Package "Java Standard Edition 8" loaded with 4385 classes in 213 packages
[Javatar] Use default settings [JDK1.7.0u80]
[Javatar] Startup Time: 0.99s
[Javatar] Javatar usages has been sent
Package Control: Skipping automatic upgrade, last run at 2016-06-26 09:21:44, next run at 2016-06-26 10:21:44 or after

Does it pin point the problem?

spywhere commented 8 years ago

Nope, it doesn't pin point the problem. But at least this should narrow down the problem a lot, thanks to your help. I'll report in both issue once I solve the problem.

spywhere commented 8 years ago

Ah.. After checking the code from the PreBeta.1 to PreBeta.5 this definitely be from a new JDK detection algorithm (introduced in PreBeta.3) since a new one required JAVA_HOME environment to be set in order to use. However, as a feature request in #53 this behaviour should be optional hence that's why Javatar cannot find the JDK. I'll adjust the JDK detection algorithm again and see if it works.

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 :)