I want to install BlueJ manually for portability reason. I have set Java_Home and add Java bin directory to path environment variable. I'm using a symlink on c:\java which points to d:\java on sd card.
Why BlueJ does not take them into account still pretending it cannot detect jdk.
Update : Eclipse is OK so is there something specific with BlueJ and Jdk 1.8 ?
I've just done a clean install of BlueJ and JDK 1.8 on separate drives to replicate your problem. I made a symlink to the JDK and put that in JAVA_HOME
and PATH
(from your use of C:\
syntax, I guessed you were on Windows, so I tested on Windows 8.1).
I too found that the setting of environment variables was ignored by BlueJ in selecting a JDK to use when it is running. I could change JDK by using the companion program Select BlueJ VM, but could not enter a symlink there (I believe on earlier versions, changing VM was a setting on the start menu, not a separate program).
I found that BlueJ stores that path to the JDK it uses in the following registry key
HKEY_CURRENT_USER\Software\BlueJ\BlueJ\3.1.5\CurrentVM
Note the root could be HKEY_USERS
or HKEY_LOCAL_MACHINE
depending on whether you installed for one user or all users of the machine.
The issue is that this key is set automatically if your system has only one VM available at runtime, or on the first run of BlueJ or with the Select BlueJ VM program at any time later. The options offered to you there are the JDK's that the launcher can detect (via the registry) on your system at that moment. Once that value is set, it is not changed dynamically at runtime to reflect JAVA_HOME
. Even using the "Browse" option from the options, I could not set the symlink as the JDK location via the GUI.
You can, however, manually change the value of that registry key (e.g. via regedit
) to your symlink value (tested and verified OK - might need administrator permissions).
I looked at the source code to determine how CurrentVM
is set.
After a fairly short trawl (kudos to BlueJ devs for good naming), I eventually worked out that the actual code used to launch BlueJ is the C++ file in \package\winlaunch\bjlaunch.cc
(source file mercurial link here).
That simply checks for the value of the registry key and, if it doesn't exist, if calls findRegistryVMs()
, which checks the registry (NOT environment variables) for available VMs and offers those to the user. So, there doesn't appear to be a way to get BlueJ to use the value from JAVA_HOME
without a manual registry edit.
N.B. If you do manually change this key value to the Symlink, you can change where the symlink links to and (with a restart) BlueJ will use whichever JDK the symlink linked to. Again, tested and verified on Windows 8.1
N.B. 2 At first, things looked optimistic: in Installer.java
there is a method called findJavaPath()
that first checks
String javaHome = System.getProperty("java.home");
before having a few guesses if that doesn't work. So it looks like it should respect the value of JAVA_HOME
at install time. However, it seems to only use that to check that there is a compatible (1.6+) version of Java available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With