diff --git a/src/main/java/com/liferay/ide/idea/server/LiferayServerCommandLineState.java b/src/main/java/com/liferay/ide/idea/server/LiferayServerCommandLineState.java index 96939b472..936864f19 100644 --- a/src/main/java/com/liferay/ide/idea/server/LiferayServerCommandLineState.java +++ b/src/main/java/com/liferay/ide/idea/server/LiferayServerCommandLineState.java @@ -106,7 +106,8 @@ protected JavaParameters createJavaParameters() throws ExecutionException { ParametersList vmParametersList = javaParameters.getVMParametersList(); - String[] runtimeStartVMArgs = portalBundle.getRuntimeStartVMArgs(); + String[] runtimeStartVMArgs = portalBundle.getRuntimeStartVMArgs( + JavaParametersUtil.createProjectJdk(liferayServerConfiguration.getProject(), jrePath)); Stream.of( runtimeStartVMArgs diff --git a/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java b/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java index b5e0287a4..0e970f7dd 100644 --- a/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java +++ b/src/main/java/com/liferay/ide/idea/server/portal/PortalBundle.java @@ -14,6 +14,8 @@ package com.liferay.ide.idea.server.portal; +import com.intellij.openapi.projectRoots.Sdk; + import java.nio.file.Path; /** @@ -29,7 +31,7 @@ public interface PortalBundle { public String[] getRuntimeStartProgArgs(); - public String[] getRuntimeStartVMArgs(); + public String[] getRuntimeStartVMArgs(Sdk sdk); public String getType(); diff --git a/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java b/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java index 64b50feb5..fda1ace8d 100644 --- a/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java +++ b/src/main/java/com/liferay/ide/idea/server/portal/PortalTomcatBundle.java @@ -14,12 +14,19 @@ package com.liferay.ide.idea.server.portal; +import com.intellij.openapi.projectRoots.JdkUtil; +import com.intellij.openapi.projectRoots.Sdk; + +import com.liferay.ide.idea.util.CoreUtil; import com.liferay.ide.idea.util.FileUtil; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.jar.Attributes; + +import org.osgi.framework.Version; /** * @author Simon Jiang @@ -70,8 +77,8 @@ public String[] getRuntimeStartProgArgs() { } @Override - public String[] getRuntimeStartVMArgs() { - return _getRuntimeVMArgs(); + public String[] getRuntimeStartVMArgs(Sdk sdk) { + return _getRuntimeVMArgs(sdk); } @Override @@ -79,7 +86,7 @@ public String getType() { return "tomcat"; } - private String[] _getRuntimeVMArgs() { + private String[] _getRuntimeVMArgs(Sdk sdk) { List args = new ArrayList<>(); Path tempPath = FileUtil.pathAppend(bundlePath, "temp"); Path endorsedPath = FileUtil.pathAppend(bundlePath, "endorsed"); @@ -87,7 +94,22 @@ private String[] _getRuntimeVMArgs() { args.add("-Dcatalina.base=" + bundlePath); args.add("-Dcatalina.home=" + bundlePath); args.add("-Dfile.encoding=UTF8"); - args.add("-Djava.endorsed.dirs=" + endorsedPath); + + String jdkVersionString = JdkUtil.getJdkMainAttribute(sdk, Attributes.Name.SPECIFICATION_VERSION); + + if (!CoreUtil.isNullOrEmpty(jdkVersionString)) { + Version jdkVersion = Version.parseVersion(jdkVersionString); + + Version jdk8Version = Version.parseVersion("1.8"); + + if (jdkVersion.compareTo(jdk8Version) <= 0) { + args.add("-Djava.endorsed.dirs=" + endorsedPath); + } + } + else { + args.add("-Djava.endorsed.dirs=" + endorsedPath); + } + args.add("-Djava.io.tmpdir=" + tempPath); args.add("-Djava.net.preferIPv4Stack=true"); args.add("-Djava.util.logging.config.file=" + FileUtil.pathAppend(bundlePath, "conf/logging.properties")); diff --git a/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java b/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java index 4fbb2b3d9..256af2562 100644 --- a/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java +++ b/src/main/java/com/liferay/ide/idea/server/portal/PortalWildFlyBundle.java @@ -14,6 +14,8 @@ package com.liferay.ide.idea.server.portal; +import com.intellij.openapi.projectRoots.Sdk; + import com.liferay.ide.idea.util.FileUtil; import com.liferay.ide.idea.util.ListUtil; @@ -86,7 +88,7 @@ public String[] getRuntimeStartProgArgs() { } @Override - public String[] getRuntimeStartVMArgs() { + public String[] getRuntimeStartVMArgs(Sdk sdk) { List args = new ArrayList<>(); args.add("-Dorg.jboss.resolver.warning=true");