New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JRE 8 on non-java project #5161

Closed
eapache opened this Issue Nov 24, 2015 · 4 comments

Comments

Projects
None yet
5 participants
@eapache

eapache commented Nov 24, 2015

We have a golang project whose test suite relies on running a java server process. This has historically been quite simple; we download and run the java process locally in our before_install and everything works fine.

However, the latest version of this java server requires JRE8 which (as far as I can tell) is not installed by default on the images. Since this is a language: go project not a language: java one, all of the various "use java 8" stanzas I have tried seem to be ignored.

How do I tell travis to use JRE 8 to run our server, on a project which is still actually a go language project?

@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Nov 24, 2015

Member

On non-JVM images, you would have to manage $PATH yourself. Basically, https://github.com/travis-ci/travis-cookbooks/blob/master/cookbooks/travis_java/templates/ubuntu/jdk_switcher.sh.erb

if [[ -d "/usr/lib/jvm/java-8-oracle-$ARCH_SUFFIX" ]] ; then
    # Currently unused, because the `travis_java` cookbook doesn't create this architecture specific symbolic link
    ORACLEJDK8_UJA_ALIAS="java-8-oracle-$ARCH_SUFFIX"
    ORACLEJDK8_JAVA_HOME="/usr/lib/jvm/java-8-oracle-$ARCH_SUFFIX"
else
    ORACLEJDK8_UJA_ALIAS="java-8-oracle"
    ORACLEJDK8_JAVA_HOME="/usr/lib/jvm/java-8-oracle"
fiswitch_to_oraclejdk8 () {
    echo "Switching to Oracle JDK8 ($ORACLEJDK8_UJA_ALIAS), JAVA_HOME will be set to $ORACLEJDK8_JAVA_HOME"
    sudo $UJA --set "$ORACLEJDK8_UJA_ALIAS"
    export JAVA_HOME="$ORACLEJDK8_JAVA_HOME"
}

(Obviously, you may not use sudo on containers.)

Member

BanzaiMan commented Nov 24, 2015

On non-JVM images, you would have to manage $PATH yourself. Basically, https://github.com/travis-ci/travis-cookbooks/blob/master/cookbooks/travis_java/templates/ubuntu/jdk_switcher.sh.erb

if [[ -d "/usr/lib/jvm/java-8-oracle-$ARCH_SUFFIX" ]] ; then
    # Currently unused, because the `travis_java` cookbook doesn't create this architecture specific symbolic link
    ORACLEJDK8_UJA_ALIAS="java-8-oracle-$ARCH_SUFFIX"
    ORACLEJDK8_JAVA_HOME="/usr/lib/jvm/java-8-oracle-$ARCH_SUFFIX"
else
    ORACLEJDK8_UJA_ALIAS="java-8-oracle"
    ORACLEJDK8_JAVA_HOME="/usr/lib/jvm/java-8-oracle"
fiswitch_to_oraclejdk8 () {
    echo "Switching to Oracle JDK8 ($ORACLEJDK8_UJA_ALIAS), JAVA_HOME will be set to $ORACLEJDK8_JAVA_HOME"
    sudo $UJA --set "$ORACLEJDK8_UJA_ALIAS"
    export JAVA_HOME="$ORACLEJDK8_JAVA_HOME"
}

(Obviously, you may not use sudo on containers.)

@BanzaiMan BanzaiMan added the java label Nov 24, 2015

@BanzaiMan BanzaiMan closed this Dec 14, 2015

@mmkal

This comment has been minimized.

Show comment
Hide comment
@mmkal

mmkal Oct 28, 2016

@eapache given that it's been nearly a year, I image you've got the above to work or otherwise figured this out by now. But for anyone reading this from the future, adding this to .travis.yml worked for me:

before_install: 
  - sudo apt-get install oracle-java8-set-default

mmkal commented Oct 28, 2016

@eapache given that it's been nearly a year, I image you've got the above to work or otherwise figured this out by now. But for anyone reading this from the future, adding this to .travis.yml worked for me:

before_install: 
  - sudo apt-get install oracle-java8-set-default
@sideshowbarker

This comment has been minimized.

Show comment
Hide comment
@sideshowbarker

sideshowbarker Nov 25, 2016

For travis builds where you don’t enable sudo, this refinement of #5161 (comment) works:

addons:
  apt:
    packages:
      - oracle-java8-set-default

sideshowbarker commented Nov 25, 2016

For travis builds where you don’t enable sudo, this refinement of #5161 (comment) works:

addons:
  apt:
    packages:
      - oracle-java8-set-default

nicoxx added a commit to gator-life/gator.life that referenced this issue Dec 2, 2016

Try to fix new error in travis (missing jre)
ERROR: (gcloud.beta.emulators.datastore.start) To use the Google Cloud Datastore emulator, a Java 7+ JRE must be installed and on your system PATH

following travis-ci/travis-ci#5161

ab added a commit to rest-client/rest-client that referenced this issue Feb 18, 2017

@rainerhahnekamp

This comment has been minimized.

Show comment
Hide comment
@rainerhahnekamp

rainerhahnekamp Jun 5, 2017

In my case I also had to set JAVA_HOME since some of my build tools depend on it. So the answer from @BanzaiMan is the complete one.

rainerhahnekamp commented Jun 5, 2017

In my case I also had to set JAVA_HOME since some of my build tools depend on it. So the answer from @BanzaiMan is the complete one.

@Thrameos Thrameos referenced this issue Jun 19, 2017

Merged

Bulletproof #229

FND added a commit to complate/complate-stream that referenced this issue Jan 3, 2018

FND added a commit to complate/complate-stream that referenced this issue Jan 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment