Payara server 5.192: cannot start with JDK11 on IntelliJ - java

I can start Payara v5.192 with JDK11 via command line, but it breaks after trying to start it via IntelliJ with the following error:
-Xbootclasspath/p is no longer a supported option
And I can't even start it via terminal any longer.
This is part of the IntelliJ log:
C:\Program Files\Java\jdk-11.0.3\bin\java.exe
-cp
D:/Program Files/payara-5.192/glassfish/modules/glassfish.jar
-XX:+UnlockDiagnosticVMOptions
-XX:NewRatio=2
-Xbootclasspath/p:D:\Program Files\payara-5.192\glassfish/lib/grizzly-npn-bootstrap-1.8.1.jar
[...]
My project is configured to use JDK 11.0.3, what might the issue be?
EDIT: I'm using IntelliJ 2019.1.3 on Windows, I don't get this issue on Debian
EDIT2: apparently the configuration changes after starting the domain with IntelliJ, here's domain.xml respectively before and after: https://pastebin.com/HAzFgkGn -> https://pastebin.com/F3r3nWet

I've encountered the same error myself, on macOS High Sierra. The reason for me was a conflict between the JDK version I'm running asadmin by default (1.8), and what IntelliJ put in the domain.xml (11.0.1).
One workaround, besides updating your domain.xml, is to fix the JDK used by asadmin, e.g. by setting the AS_JAVA parameter in glassfish/config/asenv.conf.
EDIT: Since IntelliJ ships with a bundled JDK 1.8, I believe asadmin is run using that instead of the configured JDK 11 causing the conflict -- asadmin appears to check the JDK it was run with and make some (in this case) wrong assumptions.
EDIT 2: JB SDK is not related. The asadmin command is run using the JDK that's in path, instead of the one configured to the domain. You will get this error if your default (in path) JDK is <9, and your JDK configured to your domain is >=9, as the parameters for bootclasspath of npn are parameterized on the running JDK version.
EDIT 3: Reported and confirmed as a bug: https://github.com/payara/Payara/issues/4025
EDIT 4: The fix is merged to the repository, and is on track for the 5.193 release next month.

Related

Java with maven wouldn't build: Cannot run program "cmd" "Malformed argument has embedded quote"

I've a fresh install of netbean 11.1.
Now I'm trying to build a project but I get the following error output:
Cannot run program "cmd" (in directory "C:\projects\open"): Malformed
argument has embedded quote: "C:\Program
Files\NetBeans-11.1\netbeans\java\maven\bin\mvn.cmd"
cd C:\projects\open; "JAVA_HOME=C:\\Program Files\\Java\\jdk-11.0.5" cmd /c "\"\"C:\\Program Files\\NetBeans-11.1\\netbeans\\java\\maven\\bin\\mvn.cmd\" -DskipTests=true -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans-11.1\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 clean install\"" Cannot run program "cmd" (in directory "C:\projects\open"): Malformed argument has embedded quote: "C:\Program Files\NetBeans-11.1\netbeans\java\maven\bin\mvn.cmd" -DskipTests=true -Dmaven.ext.class.path="C:\Program Files\NetBeans-11.1\netbeans\java\maven-nblib\netbeans-eventspy.jar" -Dfile.encoding=UTF-8 clean install
I've build this project with netbeans 11.1 before but have a new pc.
and a fresh install, tho I'm sure there was no problem last time I tried to install everything.
Although this problem can be fixed by installing jdk1.8.0_221, but actually you don't need to downgrade your JDK. Just try these:
First exit netbeans IDE if it's open, then open netbeans configuration file from here: netbeans-Install-Dir/etc/netbeans.conf
(Note: for me netbeans-Install-Dir is C:\Program Files\NetBeans 8.2\etc)
Add the below arguments
-J-Djdk.lang.Process.allowAmbiguousCommands=true
to the beginning of the string that you find at this line:
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m ......."
Sample screenshot as shown below:
4. Save the change and start your netbeans IDE.
I have checked the release notes for JDK 13.0.1 at https://www.oracle.com/technetwork/java/javase/13-0-1-relnotes-5592797.html#JDK-8221858
This behavior is a regression from a security fix for JDK-8221858 (not public). Follow the link for a full description. The fix is part of JDK 8u231, JDk 11.0.5, 13.0.1 etc.
To resolve this problem, append -J-Djdk.lang.Process.allowAmbiguousCommands=true to netbeans_default_options in <netbeans-dir>\etc\netbeans.conf.
I had this error with adopt8-hotspot (AdoptOpenJDK-1.8.0_232-b09) and sbt-0.13.X for an old project.
Problem solved after setting the environment variable in windows via
set JAVA_TOOL_OPTIONS=-Djdk.lang.Process.allowAmbiguousCommands=true
Did you by any chance install the latest critical update for java? jdk 1.7_241? I installed that today and was having the exact same problem. I downgraded my jdk version and it solved it completely.
EDIT: Apologies, I noticed you're using netbeans 11.1 so you probably have a later java version, in any case, you could try downgrading your java version to a previous release if you happened to update it today as the other version might have the same problem.
At the time that I'm writing, I had only JDK13 installed only on my machine. After unzipped my netbeans I've got the same problem with the internal maven of my netbeans 11.1.
Apparently netbeans 11.1 does not work properly with the JDK13. I just installed the JDK 8 and the problem now is solved, without any additional configuration or parameter change.
Nontheless, since I need the JDK13, I have both installed but my netbeans.conf file is pointing to JDK8. Later, you can define the new Java platform in netbeans project configuration.
I hope this might help.
Cheers!
just add -J-Djdk.lang.Process.allowAmbiguousCommands=true to netbeans_default_options in netbeans.conf
It seems to happen with all recently released jdk version (11.0.5 and 13.0.1 at least), even with the latest Netbeans 11.2vc1 (and witnessed on NB 11.1 too).
Downgrade your jdk to 11.0.4 or 13.0.0. It fixed the issue for me
The problem also occurs in version jdk-8u231. Fixing installing jdk-8u221 version
Apache NetBeans 11.1 does indeed not support JDK 13, that's what the upcoming Apache NetBeans 11.2 is for -- latest beta: bit.ly/apache-netbeans-11-2-beta-3
I had the same problem with oracle jdk 13.0.1 and netbeans 11.1, but it worked for me with openjdk 13.0.1 (https://jdk.java.net/13/).

How to set the correct path for JRE and JDK while building through jenkins in CentOS 7?

I am facing an issue with the jenkins build in one of our servers.
Issue is :
[ERROR] PATH_TO_FILE/EventsServiceImpl.java:[1592,137] method references are not supported in -source 1.5
EventsServiceImpl.java:[1592,137] contains the following code.
List<String> androidDevicesList = deviceIds.getDeviceIds().stream().map(Object::toString)
.collect(Collectors.toList());
By the looks of the issue, it is saying that the jenkins build is taking 1.5 to build the code. where the above code needs java 8 to compile. I have done everything to set the path correctly. I have checked the $JAVA_HOME path in the server. And it points to the correct JRE version. i.e. 1.8.0_111
I also checked my Jenkins JDK path and it is correct as far as I knew.
It is working fine in my local system. My Eclipse compiles it without any issue. But if I change the java compiler from 1.8 to 1.7 / 1.5, it is throwing the error.
My System Config:
OS: Windows 7
JDK: 8
JRE: 1.8.0_31
Server Configurations:
OS: Cent OS 7
JDK: 8
JRE: 1.8.0_111
I don't know, exactly what is the issue? Is it the issue with Jenkins? or is it the issue with Java compiler path in the server? Or is it the issue with Mavan in the server.
And also I have ran sample java file in the server with the above code in it. I ran without any issue. I am able to compile the code and build the code and saw the output.
The "-source 1.5" indicates that the java compiler, even though JDK 8, is being told to compile the code at JDK 5 level. It's not possible to tell definitively where this is coming from given the information posted. Please post your pom.xml file or check it (see this for more info) for a
<source>
tag. Also check the Build section of your Jenkins project configuration to make sure it isn't being set as a command line option there.

Incompatible JVM in GGTS (Eclipse) and JAVA 1.8

Having some problem with running a grails application in GGTS (eclipse) due to upgrade to Java 1.8.
The stack starts with:
Mar 05, 2015 3:51:31 PM org.springsource.loaded.jvm.JVM copyMethod
SEVERE: Problems copying method. Incompatible JVM?
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springsource.loaded.jvm.JVM.copyMethod(JVM.java:134)
at org.springsource.loaded.ri.OriginalClassInvoker.createJavaMethod(OriginalClassInvoker.java:68)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlClassGetDeclaredMethods(ReflectiveInterceptor.java:151)
at org.codehaus.groovy.reflection.CachedClass$3$1.run(CachedClass.java:84)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:81)
...
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:236)
at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:264)
Caused by: java.lang.IllegalArgumentException: Can not copy a non-root Method
at java.lang.reflect.Method.copy(Method.java:151)
... 280 more
I used to run the same application in Java 1.7. My colleagues upgraded to 1.8 and no longer able to run it.
I tested with SUN JDK and now I am on OpenJDK again and that does not help
Current JDK openjdk version "1.8.0_40"
JAVA_HOME, JAVA_PATH and any other variable seems to point to the correct JDK installation. I have removed all the previous (JDK 1.6 & 1.7 from the OS to be sure that there is no reference to them).
For some reason GGTS still complains for a wrong JVM. I understand the error might be related to a compiler 1.7 trying to compile files in the 1.8, but I am not sure where this reference is comming from in eclipse.
My Eclipse installation information lists the following under Java:
-vm
/usr/lib64/jvm/jre-1.8.0-openjdk/bin/java
eclipse.home.location=file:/home/arb/dev/applications/ggts-3.6.3.SR1/
eclipse.launcher=/home/arb/dev/applications/ggts-3.6.3.SR1/GGTS
eclipse.launcher.name=GGTS
eclipse.p2.data.area=#config.dir/../p2
eclipse.p2.profile=DefaultProfile
eclipse.product=org.springsource.ggts.ide
eclipse.startTime=1425566898624
eclipse.stateSaveDelayInterval=30000
eclipse.vm=/usr/lib64/jvm/jre-1.8.0-openjdk/bin/java
eclipse.vmargs=-Dgrails.console.enable.interactive=false
-Dgrails.console.enable.terminal=false
-Djline.terminal=jline.UnsupportedTerminal
-Dgrails.console.class=grails.build.logging.GrailsEclipseConsole
-Dosgi.requiredJavaVersion=1.6
-Xms60m
-Xmx1024m
Version 1.8.0_40 and 1.8.0_45 has breaking updates with grails.
Spring can not copy non-Root methods.
Since the initial posting a workaround has been developed.
aclement commented on Mar 5
Here is the build:
http://repo.spring.io/libs-snapshot-local/org/springframework/springloaded/1.2.2.BUILD-SNAPSHOT/springloaded-1.2.2.BUILD-SNAPSHOT.jar
To test it under grails, what I do is go into the grails folder:
grails-2.5.0/lib/org.springframework/springloaded/jars
I then rename the spring loaded jar that is there and put in a symlink
to the jar above. It used to be that you could just modify the
startGrails script to point to the new version, but now due to the
forking I find you need to do the symlink thing. Or drop that jar into
this folder and rename it to match the expectations of grails (rename
it from springloaded-1.2.2.BUILD-SNAPSHOT.jar to
springloaded-1.2.0.RELEASE.jar)
If you want to rollback instead
Grails is natively supported in 1.8.0_25, 1.8.0_31
http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-8u25-oth-JPR
Once you have a compatible java version clean your grails project.
Ensure that your java path variables are set to point to your expected version.
set JAVA_HOME=C:\java\jdk1.8.0_25
set PATH=%JAVA_HOME%\bin;%PATH%;
It's a problem related to jdk8u40, go back to jdku31. It works in that version.
I'm running into the same problem both in windows and linux environments.
I updated my springloaded jar to version 1.2.4.BUILD-SNAPSHOT (from 1.2.1) and that resolved the issue. (Latest version can be found in the Spring repo)
Go to your local Grails lib directory to find springloaded jar. For me that was /usr/local/Cellar/grails/2.4.4/libexec/lib/org.springframework/springloaded/jars/
remove existing 1.2.1 jars (I removed pom file, too, but not necessary)
download latest springloaded jar and place into the jars subdir:
wget http://repo.spring.io/libs-snapshot-local/org/springframework/springloaded/1.2.4.BUILD-SNAPSHOT/springloaded-1.2.4.BUILD-SNAPSHOT.jar
After doing that, everything works. (Clues used from previous answer: https://github.com/spring-projects/spring-loaded/issues/98)
Step 1 : Download this jar
step 2 : put it into the grails folder: grails-2.4.1/lib/org.springframework/springloaded/jars
should be enough , restart IDE
Root cause, work-arounds and news on fixes here: https://github.com/spring-projects/spring-loaded/issues/98
I am running Grails 2.4.3 and also had problems moving from jdk1.8.0_31 to jdk1.8.0_40 and had to go back to jdk1.8.0_31
Loading Grails 2.4.3
...
SEVERE: Problems copying method. Incompatible JVM?
java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.IllegalArgumentException: Can not copy a non-root Method
at java.lang.reflect.Method.copy(Method.java:151)
From https://github.com/spring-projects/spring-loaded/issues/98 and worked to me
wget repo.spring.io/libs-snapshot-local/org/springframework/springloaded/1.2.3.BUILD-SNAPSHOT/springloaded-1.2.3.BUILD-SNAPSHOT.jar -O ~/.gvm/grails/2.4.4/lib/org.springframework/springloaded/jars/springloaded-1.2.1.RELEASE.jar
Two Step To Make it Work
1. Download JDK Lower Version:
Install jdk1.8.0_25 from link http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-8u25-oth-JPR. It's the lower version of JDK as grails dont support higher version. Maybe They'll include this in latest version soon.
2. Set Up Environment Variables:
Don't forget to change the Enviromental variables for jdk, you have to just edit Path Variables and JavaHome Variable from "C:\Program Files\Java\jdk1.8.0_'LatestVersion'" to "C:\Program Files\Java\jdk1.8.0_25" .
Changing the springloaded version in my pom.xml did the trick.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
When I was experiencing the issue my springloaded version was 1.2.1.RELEASE
I thought I should add my two pence worth on this topic. Recently I hit the same issue trying to upgrade an ancient app to 2.4.4. The reason for my post is because all of the above instructions are a little out of date and whilst in most cases it may appear to work. The moment you introduce mysql drivers all of the above mentioned versions of spring loaded hit a new issue around incompatibility and Non-root when attempting to trigger the database.
I got ggts fully working with JDK 1.8_065. To make it work get hold of springloaded-1.2.5.RELEASE.jar Put this into grails-2.4.4/lib/org.springframework/springloaded/jars/ folder.
When you install ggts inside the ggts-bundle folder is grails-2.4.4. So put the file in the above location within the ggts-bundle folder. Unless you have changed configuration.
Re-launch GGTS
I spent ages on it and thought I should update the instructions.
Also the other thing that I hit issues around was forking under grails 2.4.4 with my uprade and ended up setting
grails.project.fork = []
In my BuildConfig.groovy

IntelliJ, can't start simple web application: Unable to ping server at localhost:1099

I'm trying to make a simple web app in IntelliJ by following this tutorial:
http://wiki.jetbrains.net/intellij/Creating_a_simple_Web_application_for_Tomcat_in_IntelliJ_IDEA_12
I believe my Tomcat is installed correctly since I see the tomcat pictures when I go to
http://localhost:8080/
I've followed all the steps up until the part it tells me to run index.jsp, at which point I get the error:
Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: nodename nor servname provided, or not known
I see this in the log:
Application Server was not connected before run configuration stop, reason:
Unable to ping server at localhost:1099
This 1099 comes from the JMX port in Run -> Edit Configurations.
How do I fix this?
To fix this you need add your machine name in the /etc/hosts file to point to localhost(127.0.0.1).
You can find your machine name by running the following command:
$ hostname
macbook-pro
From the output above you know your hostname is "macbook-pro".
Edit "/etc/hosts" file and add that name at the end of line that lists 127.0.0.1
127.0.0.1 localhost macbook-pro
Save the file.
Now you IntelliJ should be able to start your server.
See that the tomcat you are using is compatible with the Java version. For me the issue was Tomcat-9 required Java-8. If you have a older version of Java, you could use Tomcat-7 to test.
I added my hostname to /etc/hosts on localhost.
Added JAVA_HOME
but still it showed the same error. In the console, there was output:
Unable to start as CATALINA_BASE contains a colon (:) character
I solved the problem by going to Edit configurations -> Startup/Connection -> changing CATALINA_BASE value to the tomcat installation folder. Before that, it was
CATALINA_BASE: C:\Program Files\Apache Software Foundation\Tomcat 8.0
which can't be correct on a linux machine ;)
For those who encounter this when you just recently updated IntelliJ (In my case 2019.2).
I am using JBoss server so i tried to run standalone.bat in the command line and I saw the real issue on the console.
It can be different to yours, but in my case I saw:
failure description: "WFLYSRV0137: No deployment content with
And on that error I was able to fix this by removing the items (war or ear) inside the <deployments/> node in my standalone.xml
Hope this helps for those using JBoss+IntelliJ
FYI Under certain network conditions your hostname may change or be incorrect. If you are on a mac the following will let you set your hostname fairly permanently:
sudo scutil --set HostName correct-name
This appears to be a problem with the way mac is handling reading the /etc/hosts file. See for example http://youtrack.jetbrains.com/issue/IDEA-96865
Adding the hostname to the hosts file as bond described should not be required, but it does solve the problem.
My problem was that tomcat 8 and higher are not compatible with java 6. Changing to java 7 solved it.
I had similar issue when I entered very big port here:
But when I corrected it to something smaller which is in offset range:
Issue was resolved.
I had same problem. In "Edit Configurations.." -> "Tomcat Server" I changed JRE from "Default" to my current version with SDK directory address (like C:\Program Files\Java\jdk1.8.0_121\jre)
My Tomcat version is 8.5.31
This error came to me when I configured (wrong) 3 Gb memory where there was none. IntelliJ does shows the real error message (Could not reserve enough space for object heap) in the Output frame.
I was confused, and attracted by the message in the Event Log, which is to be ignored in this case.
None of the answers above worked for me. In the end I figured out it was an configuration error (I used the android SDK and not Java SDK for compilation).
Got to
[Right Click on Project] --> Open Module Settings --> Module --> [Dependendecies] and make sure you have configured and selected the Java SDK (not the android java sdk)
I meet this question when i use intellij 15.0,then i update to 15.02 version. after that, I edit configurations and reset the Default JRE to my own JRE.It works well for me;
I added the following VM Options and it worked for me:
-Dcom.sun.management.jmxremote=
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
I solve this problem adding the environment variables JAVA_HOME(C:\Program Files\Java\jdkx.x.x_xx) and JRE_HOME.
I had the same problem of "Unable to ping server at localhost:1099" while I was using intellij 2016 version.
However, as soon as I upgraded it to 2017 version(Ultimate 2017.1) which is installed using "ideaIU-2017.1.exe" the problem disappeared.
I had this issue when running Tomcat 6.0.53 on Mac OS Sierra with Intellij IDEA to deploy Spring projects.
This problem was solved after changing the Tomcat version to the 'tar.gz' one from official site. It seems the 'zip' one is for windows.
Setting project's SDK in IntelliJ (File > Project Structure > Project:Project SDK) worked for me
If your tomcat contains file setenv.sh ([YOUR_CATALINA_HOME]/bin/setenv.sh) it may redefine the JAVA_OPTS variable that JIdea uses to set up JMX, so you have to add them there:
export JAVA_OPTS ="$JAVA_OPTS <whatever was in setenv.sh>"
echo $JAVA_OPTS
Below is the error I observed :
to resolve, in my case, I exit intelliJ and renamed folder ".idea" to ".idea_old" (so that I don't loose old config) and restarted intelliJ, It created a new ".idea" folder and I provided new tomcat configuration. On running tomcat this issue was removed.
On top pointing my hostname to 127.0.0.1 in hosts (just run hostname in cmd to get it) as well as doing what David GC mentioned, for me the error cleared and debugging worked when I went into the tomcat configuration and changed the debugging startup script from startup.bat (which was just my monkeying around) back to the catalina.bat start default.
I had same issue and my mistake was, I was trying to start tomcat server with incompatible version of JDK and installed Apache tomcat server. In my case I had installed JDK 7 with Apache tomcat 9. For Apache 9 JDK should be >= 8.
For compatibility check this https://tomcat.apache.org/whichversion.html
For me, it was a much different solution since it was running on a virtualbox, so I had to edit the hosts file and add the virtualbox as a localhost
127.0.0.1 VirtualBox-blahblah
In windows environment just check the PATH environment variable if Oracle JRE runtime refreshed the path and put himself at the very beginning of the path. In this case even if the JAVA_HOME AND JRE_HOME points to the correct JDK, the JRE will have precedence. And this case IntelliJ will not start Tomcat instance with the mentioned error message.
If you are using java 7 then make sure you have Tomcat 7
brew install tomcat#7
and update run configuration to Tomcat 7
Tomcat 9 is working with java 8
I'm leaving an answer for the jboss user.
If any of the people experiencing this error are using jboss, make sure the JBOSS_HOME location is correct.
If we have the installed the compatible tomcat version for the application JAVA jdk version, we can resolve this issue easily.
In my case, when I am using Tomcat 10.1.0.M4 with JAVA JDK 1.8 I faced this issue. When I downgrade my tomcat version to 9.0.41, the issue resolved for me.
You can find the compatible tomcat version for the JAVA JDK here..
http://tomcat.apache.org/whichversion.html

Jenkins, specifying JAVA_HOME

I installed openjdk-6-jdk on my ubuntu box using apt-get.
In system info jenkins is telling me Java.Home is /usr/lib/jvm/java-6-openjdk/jre
However when I specify that directory as JAVA_HOME in Jenkins : "configure system", it returns error message saying that directory does not look like a jdk directory.
it is also failing to pick up my maven install.
Am I missing something obvious ?
Your JAVA_HOME variable must be set to /usr/lib/jvm/java-6-openjdk and it must be available for the user that starts Jenkins.
From Kyle Strand comment:
As of April 2015 (I think), Jenkins requires Java7. Also note that the java binary path (JAVA) must be set to the correct version if the system default is still Java 6. Finally, for anyone wondering where these variables are set, it's in a config file listed with the installation instructions on the Jenkins webpage (e.g. for Debian it's /etc/default/jenkins).
Using Jenkins 2 (2.3.2 in my case), the right way seems to insert the following into your pipeline file:
env.JAVA_HOME="${tool 'jdk1.8.0_111'}"
env.PATH="${env.JAVA_HOME}/bin:${env.PATH}"
"jdk1.8.0_111" beeing the name of the java configuration initially registered into Jenkins
On CentOS 6.x and Redhat 6.x systems, the openjdk-devel package contains the jdk. It's sensible enough if you are familiar with the -devel pattern used in RedHat, but confusing if you're looking for a jdk package that conforms to java naming standards.
I was facing the same issue and for me downgrading the JAVA_HOME from jdk12 was not the plausible option like said in the answer. So I did a trial and error experiment and I got the Jenkins running without even downgrading the version of JAVA_HOME.
Steps:
open configuration $ sudo vi /etc/init.d/jenkins
Comment following line:
#JAVA=`type -p java`
Introduced the line mentioned below. (Note: Insert the specific path of JDK in your machine.)
JAVA=`type -p /usr/lib/jdk8/bin/java`
Reload systemd manager configuration: $ sudo systemctl daemon-reload
Start Jenkins service: $ sudo systemctl start jenkins
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Sun 2020-05-31 21:05:30 CEST; 9min ago
Docs: man:systemd-sysv-generator(8)
Process: 9055 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCCESS)
I just wanted to add a solution for Windows machines.
Windows Server 2008 R2 Standard, SP1
Jenkins 2.89.4
Java version 8.171
Symptom: Jenkins service starts and immediately stops.
Jenkins.wrapper.log has a line indicating the incorrect path to Java:
- Starting C:\Program Files\Java\jre1.8.0_141\bin\java -Xrs -Xmx6g -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "C:\Program Files (x86)\Jenkins\jenkins.war" --httpPort=8080 --webroot="C:\Program Files (x86)\Jenkins\war"
The fix: Jenkins has the path hard-coded in jenkins.xml. Change the path to the new Java location.
<env name="JENKINS_HOME" value="%BASE%"/>
<!--
if you'd like to run Jenkins with a specific version of Java, specify a full path to java.exe.
The following value assumes that you have java in your PATH.
-->
<executable>C:\Program Files\Java\jre1.8.0_171\bin\java</executable>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
You can also use Windows Environment Variables, but I wasn't successful with that and I don't think the Java installer updates those, so you'd need to update that by hand every time anyway.
<env name="JENKINS_HOME" value="%BASE%"/>
<!--
if you'd like to run Jenkins with a specific version of Java, specify a full path to java.exe.
The following value assumes that you have java in your PATH.
-->
<executable>%JAVA_HOME%\bin\java</executable>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
openjdk-6 is a Java runtime, not a JDK (development kit which contains javac, for example). Install openjdk-6-jdk.
Maven also needs the JDK.
[EDIT] When the JDK is installed, use /usr/lib/jvm/java-6-openjdk for JAVA_HOME (i.e. without the jre part).
This is an old thread but for more recent Jenkins versions (in my case Jenkins 2.135) that require a particular java JDK the following should help:
Note: This is for Centos 7 , other distros may have differing directory locations although I believe they are correct for ubuntu also.
Modify /etc/sysconfig/jenkins and set variable JENKINS_JAVA_CMD="/<your desired jvm>/bin/java" (root access require)
Example:
JENKINS_JAVA_CMD="/usr/lib/jvm/java-1.8.0-openjdk/bin/java"
Restart Jenkins (if jenkins is run as a service sudo service jenkins stop then sudo service jenkins start)
The above fixed my Jenkins install not starting after I upgraded to Java 10 and Jenkins to 2.135
java jenkins java-home ubuntu centos
For those of you coming to this issue and have access to configure your Jenkins Agents, you can set the JAVA_HOME from the Jenkins > Nodes > "the agent name" > Configure page:
Setting "per agent" environment variables
In case anyone has similar problems, I used the default sudo apt-get installs for the relevant packages and here are the correct settings:
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
and
MAVEN_HOME=/usr/share/maven2
In Jenkins try setting JAVA_HOME to /usr/lib/jvm/java-6-openjdk
Upgrading from Ubuntu 10.0.4 to 12.0.4 we got wrong footed.
We had a JDK installation configured (auto-configured?) pointing to /usr/lib/jvm/java-6-openjdk
this no longer contained a JDK,
Changing to /usr/lib/jvm/default-java fixed, and should make for a seamless java-7 upgrade.
So in answer to the question: do not specify JAVA_HOME on Ubuntu.
In Ubuntu 12.04 I had to install
openjdk-7-jdk
then javac was working !
then I could use /usr/lib/jvm/java-7-openjdk-amd64 as path and jenkins didn't complain anymore.
Download package rpm package from http://pkg.jenkins-ci.org/redhat/ you can give additional java location like I have default 1.7 java in my system but I am using /opt/jdk1.8.0_60/bin/java for jenkins. Open jenkins startup script /etc/init.d/jenkins and add additional java here, I m case I have added /opt/jdk1.8.0_60/bin/java,
Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.
See http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
candidates="
/opt/jdk1.8.0_60/bin/java
i saw into
Eclipse > Preferences>installed JREs > JRE Definition
i found the directory of java_home
so it's
/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home

Categories