A way to start tomcat with other java - java

I am exporting variables in the setenv.sh like this:
JAVA_HOME=/home/arthur/java8
JRE_HOME=/home/arthur/java8/jre
CATALINA_HOME=/home/arthur/tomcat8
PATH=$CATALINA_HOME/bin:$PATH
PATH=$JAVA_HOME/bin:$PATH
But tomcat started from tomcat8 folder starts with java6 variable.
Why?
Thank you!

Try configuring tomcat configuration file using command
sudo vim /etc/default/tomcat7
...
The home directory of the Java development kit (JDK). You need at
least JDK version 1.5. If JAVA_HOME is not set, some common
directories for OpenJDK, the Sun JDK, and various J2SE 1.5 versions
are tried.
JAVA_HOME=/usr/lib/jvm/openjdk-6-jdk
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
...
Then restart the server
sudo service tomcat7 restart
You can use below command to check Tomcat is using which JDK
sudo service tomcat7 status

Related

Java SE 6 cannot be seen

I installed Java SE 6 from oracle
but, on the commant prompt, I get this error when trying to send any command :
Glassfish requieres JAVA SE 6, your JDK is version 0
is there anything i can do to make this work, I also installed version 10 but nothing works of these two
It's like it cannot see it at all
OS: Windows 64x
JAVA SE VER. : downloaded it from here : http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html
Command: asadmin create-domain --adminport 4848 --instanceport 8080 name
Glassfish should only require one or two environment variables, and one path.
JAVA_HOME should point to the directory where the jdk bin directory lives.
JRE_Home should point to the directory where the jre's bin directory lives.
PATH should include %JAVA_HOME%\bin;
If those are set correctly, you should be able to open a command prompt and type
java -version
and get a satisfactory response.

Start Jenkins with JDK 8 without changing system java_home

I have Jenkins 2.46.3 LTS version that i am trying to upgrade to 2.73.3 LTS version. My current java version is 1.7. How do i install and start Jenkins with 1.8 version? I am getting the following error after i copied Jenkins war file under (/usr/lib/Jenkins) and restarted the service
$ sudo service jenkins start
Starting Jenkins Jenkins requires Java8 or later, but you are running 1.7.0_97-b02 from /app_2/java/jdk1.7.0_97/jre
java.lang.UnsupportedClassVersionError: 51.0
at Main.main(Main.java:124)
Is there any way to start Jenkins using Java 8 without changing the system classpath?
Thanks,
Ann
Set JENKINS_JAVA option in /etc/sysconfig/jenkins file.
The variable name might be different depending on your operating system and package source but the /etc/sysconfig/jenkins file is usually the configuration file for your jenkins service.
Just run the war with the new java binary:
nohup <path to your new jdk8 folder>/java -jar jenkins.war > $LOGFILE 2>&1
Not sure if JAVA_HOME is needed, but you can execute the line below in the shell, before the command above, or add to the top of init script :
export JAVA_HOME=<path to your new jdk8 folder>/java
Hope that helps.

GlassFish does not start

I'm starting with the Glassfish technology. I found this impediment, after having downloaded and put on disk c: the installer, I go to the windows command screen and execute the command "asadmin start-domain", but my answer is
-jar: illegal argument.
I have already configured the JAVA_HOME and the route. But it does not work. Could you suggest something?
The version of the Glassfish Platform is 4.1.2
The Java Development Kit version is 8
Command line
asadmin start-domain
Path JAVA_HOME
In addition to Ramanlfc's comment, you will also need to check your environment variables. On Windows, you will need to add your JDK's binaries location (%JAVA_HOME%) to the system path in order to start GlassFish:
https://www.mkyong.com/java/how-to-set-java_home-on-windows-10/

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

java install tomcat as service

I'm planning to develop an application installer which, as a part of installation, installs Apache Tomcat on Linux. Does anyone know how can I programmatically install Tomcat as service on Linux.
Best
If you have Tomcat installed already, you probably need to put a start up script for Tomcat in /etc/init.d
This article has a decent start up script.
http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/
Tomcat7 (Stable release 2011 January) For Debian-base: Tested in Ubuntu 14.04.
Install Tomcat7:
sudo apt-get install tomcat7 tomcat7-docs tomcat7-admin
sudo apt-get install libtomcat7-java tomcat7-common tomcat7-examples
Start the tomcat server:
sudo service tomcat7 restart
Check whether the the tomcat is running or not by access the URL http:/127.0.0.1:8080 in browser or in terminal:
w3m http://127.0.0.1:8080
More...
If you are on a debian-base distribution, just type
sudo apt-get install tomcat6 tomcat6-admin tomcat6-examples
and you'll have a tomcat fully functional (example for Ubuntu 10.04)

Categories