Ubuntu – Using a specific version of java for teamcity

javateamcityUbuntu

I've got teamcity 10.1 running on a ubuntu box at work. This box requires java 1.7 to be installed for some of the other tools we have installed there. However teamcity (as of version 10) requires java 1.8. I cannot seem to find anywhere that I can set a specific directory for choosing java 1.8 over java 1.7 in the teamcity configuration.

How can I go about specifying the version of java for teamcity to use?

Best Answer

So I am not a expert with team city but know java & tomcat and the issues of different java major versions.

So lets first find out what is where [root@kick73 java]# cd /usr/java [root@kick73 java]# ls -l lrwxrwxrwx 1 root root 16 Apr 12 23:35 default -> /usr/java/latest drwxr-xr-x 8 root root 233 Apr 12 23:35 jdk1.7.0_101 lrwxrwxrwx 1 root root 22 Apr 12 23:35 latest -> /usr/java/jdk1.7.0_101

Here you see that latest & default point to jdk1.7.0_101

Next check to see if /usr/bin/java points to /usr/java/default

[root@kick73 java]# ls -l /usr/bin/java lrwxrwxrwx 1 root root 26 Apr 12 23:35 /usr/bin/java -> /usr/java/default/bin/java

So fare we are ok.... Now lets download latest jdk for Java 1.8.0.121. so go to https://java.com/en/download/manual.jsp#lin and select one of the middle 2 linux files depending on your machine arch. This should pull down a *.tgz file. If you get the RPM file that will not work well for you.

So transfer that to your host and lets load it into /opt (so as root)

mkdir /opt

cd /opt

cd /opt

extract the jdk using tar command

tar xvfpz jre-8u121-linux-x64.tar

So now you have java 7 in /usr/java and java 8 in /opt

Now go to where your tomcat is installed and go to bin directory. In my example my tomcat is /apps/apache-tomcat-8.0.43

cd /apps/apache-tomcat-8.0.43/bin

Next edit the file catalina.sh and the beginning has the following

JRE_HOME=/opt/jre1.8.0_121 CATALINA_HOME=/apps/apache-tomcat-8.0.43 JAVA_HOME=/opt/jre1.8.0_121

!/bin/sh

Change JRE_HOME and JAVA_HOME to point to the above example