简体   繁体   中英

Running a jar in Travis CI

Is it possible to run a jar within Travis? I'm trying to make a custom language work within Travis which I presume should be possible if I'm using a jar interpretor and define the project as a java language.

I have been trying do get it working for a while now and with no success. My latest try looks like this and outputs what's underneath.

language: java
install:
  - ls
  - java -Xmx1G -Xss32m -jar shell-stable.jar src/main.rsc

Version: 0.8.0.201510190912
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/rascalmpl/interpreter/utils/RascalManifest : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at org.rascalmpl.shell.RascalShell.main(RascalShell.java:36)
The command "java -Xmx1G -Xss32m -jar shell-stable.jar src/main.rsc" failed and exited with 1 during .

Add this:

jdk:
  - oraclejdk8

That tells Travis to use Java8.

Your error message indicates that your code expects a Java8 environment but it's instead being run in some earlier Java runtime.

If it's not actually a Java project and all you want to do to is run the jar file, try something like this:

language: generic
addons:
  apt:
    packages:
      - oracle-java8-set-default
install:
  - /usr/lib/jvm/java-8-oracle/jre/bin/java -Xmx1G -Xss32m -jar shell-stable.jar src/main.rsc

The addons: apt: packages: oracle-java8-set-default bit may be enough by itself to make Travis use the Java8 java —but to ensure Travis does, you can specify the full path to the java binary with /usr/lib/jvm/java-8-oracle/jre/bin/java (assuming you're building on Linux).

And if you specify the full path to the java binary that way, you can probably just omit the addons: apt: packages: oracle-java8-set-default part. (Upon further reflection, I guess the addons: apt: packages: oracle-java8-set-default part is always needed in this case, to get Travis to actually install Java8 at all.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM