This article is about Codeship Basic.

Java And The JVM

You will need roughly 4 minutes to read this article.

Versions And Setup


The following JDKs are installed:

  • OpenJDK 7
  • Oracle JDK 7
  • Oracle JDK 8
  • Oracle JDK 9

We provide the function jdk_switcher, available as a setup command, to choose the JDK for your builds. This function can take one of two commands, use or home:

  • use will select the given JDK by changing the java executables, and setting JAVA_HOME and JRE_HOME.
  • home will print out the value of JAVA_HOME for a given JDK (but make no modifications).

The valid values for use or home are openjdk7, oraclejdk7, oraclejdk8 and oraclejdk9. By default, OpenJDK 7 is selected. The following would be the resulting Java version, JAVA_HOME, and JRE_HOME for each JDK:

OpenJDK 7 (default)

jdk_switcher home openjdk7
# /usr/lib/jvm/java-7-openjdk-amd64
jdk_switcher use openjdk7
# /usr/lib/jvm/java-7-openjdk-amd64
echo $JRE_HOME
# /usr/lib/jvm/java-7-openjdk-amd64/jre
java -version
# java version "1.7.0_151"
# OpenJDK Runtime Environment (IcedTea 2.6.11) (7u151-2.6.11-2ubuntu0.14.04.1)
# OpenJDK 64-Bit Server VM (build 24.151-b01, mixed mode)

Oracle JDK 7

jdk_switcher home oraclejdk7
# /usr/lib/jvm/java-7-oracle
jdk_switcher use oraclejdk7
# /usr/lib/jvm/java-7-oracle
echo $JRE_HOME
# /usr/lib/jvm/java-7-oracle/jre
java -version
# java version "1.7.0_80"
# Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
# Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Oracle JDK 8

jdk_switcher home oraclejdk8
# /usr/lib/jvm/java-8-oracle
jdk_switcher use oraclejdk8
# /usr/lib/jvm/java-8-oracle
echo $JRE_HOME
# /usr/lib/jvm/java-8-oracle/jre
java -version
# java version "1.8.0_161"
# Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
# Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

Oracle JDK 9

jdk_switcher home oraclejdk9
# /usr/lib/jvm/java-9-oracle
jdk_switcher use oraclejdk9
# /usr/lib/jvm/java-9-oracle
echo $JRE_HOME
# /usr/lib/jvm/java-9-oracle/jre
java -version
# java version "9.0.4"
# Java(TM) SE Runtime Environment (build 9.0.4+11)
# Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

Build Tools

The following tools are preinstalled in our virtual machine. You can add them to your setup or test commands to start your build:

JVM-based languages

Scala, Clojure, Kotlin, Groovy and other JVM based languages should also run on Codeship. Let us know if you find something that doesn’t work as expected.


Installing dependencies through Maven is fully supported.

Dependency Cache

Codeship automatically caches the $HOME/.ivy2 and $HOME/.m2/repository directories between builds to optimize build performance. You can read this article to learn more about the dependency cache and how to clear it.

Frameworks And Testing

All build tools and test frameworks, such as JUnit, will work.

Parallel Testing

If you are running parallel test pipelines, you will want separate your tests into groups and call a group specifically in each pipeline. For instance:

Pipeline 1:

mvn test -Dtest=class_1

Pipeline 2:

mvn test -Dtest=class_2

Parallelization Modules

In addition to parallelizing your tests explicitly via parallel pipelines, some customers have found using the parallel features in JUnit and other testing frameworks to be a good way to speed up your tests.

Note that aggressive parallelization can cause resource and build failure issues, as well.

Notes And Known Issues

Due to Java version issues, you may find it helpful to test your commands with different versions via an SSH debug session if tests are running differently on Codeship compared to your local machine.


The Java Cryptography Extension (JCE) ships from Oracle by default on Java 8 and Java 9. You can also check if JCE is in limited or unlimited mode by checking the allowed key length. Limited mode will return 128 and unlimited mode will return 2147483647.

jdk_switcher use oraclejdk9
jrunscript -e 'print (javax.crypto.Cipher.getMaxAllowedKeyLength("AES"));'

Need more help?

Contact our support team or post on Stack Overflow using the tag #codeship. Did you check the status page and changelog?

There are also several code examples and sample projects available for you to get started with.

Article not helpful?

Does this article need improvement? If so, please send feedback or submit a pull request!