留言板

blade - where does it find java?

Brian Summers,修改在7 年前。

blade - where does it find java?

New Member 帖子: 13 加入日期: 09-5-28 最近的帖子
I'm baffled about where blade.exe is deciding which java to use....

The question is.... How do I tell blade.exe which version of java to use? (same question for blade on Linux)

I have automated a build using jpm, blade and gradle which has worked fine on several machines for a while but it's no longer working (on certain machines) due to blade trying to use the wrong version of java.

(I think the cause is because of a recent switch to Java 8 but knowing this doesn't help me solve the problem!)

Example:

C:\liferay\build\bin>set JAVA_HOME
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_11

C:\liferay\build\bin>set PATH
Path=C:\Program Files\Java\jdk1.8.0_11\bin;C:\Python27\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

C:\liferay\build\bin>java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

(blade.exe is an executable:)

C:\liferay\build\bin>blade
 [err] Could not find or initialize main class
java.lang.UnsupportedClassVersionError: com/liferay/blade/cli/blade : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)


Thanks for any help you can provide.
thumbnail
David H Nebinger,修改在7 年前。

RE: blade - where does it find java?

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
IIRC blade just uses the java on the path. Not having visibility in your environment and no details to whatever error you're getting, it's hard to offer up any useful suggestions.









Come meet me at the 2017 LSNA!
Brian Summers,修改在6 年前。

RE: blade - where does it find java?

New Member 帖子: 13 加入日期: 09-5-28 最近的帖子
No details?

What about the examples output provided?

These show that the correct version of Java (Java 8 I assume) is set in JAVA_HOME and also in the PATH yet blade still seems to find a different Java on the machine.

The question is, how does blade choose which Java to use?

Thanks to anyone who can advise!
thumbnail
Manish Jha,修改在6 年前。

RE: blade - where does it find java?

Junior Member 帖子: 50 加入日期: 13-2-7 最近的帖子
Could you check your path variable, does it has different java path listed than those in JAVA_HOME.
Brian Summers,修改在6 年前。

RE: blade - where does it find java?

New Member 帖子: 13 加入日期: 09-5-28 最近的帖子
No... you can see the exact PATH setting in my example.
thumbnail
Manish Jha,修改在6 年前。

RE: blade - where does it find java?

Junior Member 帖子: 50 加入日期: 13-2-7 最近的帖子
Unsupported major.minor version come when some of the class file in the war/jar is compiled with other version than java 8. For example, some class file compiled with Java 7 and some with Java 8.
Could you delete all the class using clean and build fresh.
It might resolve the issue.
thumbnail
David H Nebinger,修改在6 年前。

RE: blade - where does it find java?

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
The "blade" command is just a script; I think you can open it in a text editor to see what kind of script it contains.

On my Mac, it just uses "java ..." to launch, so there is no java specified in there, it only uses the one in the path. I'm guessing yours is the same, but even if so you could edit to force a path that works.






Come meet me at the 2017 LSNA!
Brian Summers,修改在6 年前。

RE: blade - where does it find java?

New Member 帖子: 13 加入日期: 09-5-28 最近的帖子
Not as simple as that! On Windows blade.exe is an executable.
thumbnail
Eddie Chow,修改在6 年前。

RE: blade - where does it find java?

Junior Member 帖子: 53 加入日期: 13-8-28 最近的帖子
Hey Brian I was running into the exact same issue as you and did all the checks you did (JAVA_HOME set to JDK 8 with JAVA_HOME in the PATH), but I found out that I had an old version of Java 7 installed. I uninstalled JDK 7 and reinstalled JDK 8 (just in case) and it worked after that.

Hopefully this helps with the issue that you ran into (if you haven't had it resolved already) and helps anyone in the future as this is the only thread that shows up when you google the error emoticon.
thumbnail
Christophe Cariou,修改在5 年前。

RE: blade - where does it find java?

Junior Member 帖子: 57 加入日期: 07-10-1 最近的帖子

Hi all,

 

Blade, JPM and GW use .ini files that are generated during the installation.

This files are in your <user>/.jpm/windows/bin folder.

In this .ini files, the path to jvm.dll are made from the current java version installed on the host.

 

But if you update your java later, this paths are no longer valid... 

 

So you have to update thes .ini files after each java update...

 

Regards

thumbnail
tamallah seifedine,修改在5 年前。

RE: blade - where does it find java?

New Member 帖子: 13 加入日期: 14-6-15 最近的帖子
make sure you check Environment variables versions of java , it could be just the difference between the versions of JAVA_HOME  (JDK path) and JRE_HOME  (JRE path) , that cause the problem .