# java.lang.UnsupportedClassVersionError

**URL:** <https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564>\
**Category:** Java\
**Created:** [March 12, 2020, 8:38pm UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564 "2020-03-12T20:38:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![amCap1712](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/amcap1712/32/4627_2.png) [@amCap1712](https://travis-ci.community/u/amCap1712)\
**Post date:** [March 12, 2020, 8:38pm UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564/1 "2020-03-12T20:38:10Z")

</div>

I am trying to setup CI for [https://github.com/amCap1712/pljava](https://github.com/amCap1712/pljava) using Travis. But it fails with following log:

```auto
find pljava-packaging -name \*.jar | sudo xargs java -jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/gjt/cuspy/JarX has 
been compiled by a more recent version of the Java Runtime (class file version 53.0), this 
version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

```

The complete build log and travis config is available at [https://travis-ci.org/github/amCap1712/pljava/builds/661687014](https://travis-ci.org/github/amCap1712/pljava/builds/661687014) . I am using OpenJDK9 for this build but it fails for OpenJDK14 as well. How to fix the error ?

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [March 13, 2020, 12:38am UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564/2 "2020-03-13T00:38:38Z")

</div>

Hey @amCap1712,

Try adding this into your `.travis.yml`:

```auto
travis_wait 20

```

Let me know the results and I’ll help you further.

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/amcap1712/32/4627_2.png) [@amCap1712](https://travis-ci.community/u/amCap1712)\
**Post date:** [March 13, 2020, 5:17am UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564/3 "2020-03-13T05:17:39Z")

</div>

@Montana I added it as follows:  
` install: travis_wait 20 "mvn clean install"`  
Here is the error log:

```
    travis_wait 20 "mvn clean install"
    Still running (1 of 20): mvn clean install
    The command mvn clean install exited with 127.
    Log:
    mvn clean install: command not found
    /home/travis/.travis/functions: line 607: 8889 Terminated travis_jigger "${!}" "${timeout}" "${cmd[@]}"
    The command "travis_wait 20 "mvn clean install"" failed and exited with 127 during .
```

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [March 13, 2020, 12:56pm UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564/4 "2020-03-13T12:56:56Z")

</div>

First, the error message indicates that the `org/gjt/cuspy/JarX` package, however you got it, is not compatible with the Java compiler you are using. You are using `sudo` to invoke `java` through `xargs`; `root`'s `$PATH` (and probably `$JAVA_HOME`, too) is not set up properly to use Java 9 or 14, or whatever. Unless you need the `root` privilege to accomplish the desired task, I suggest first dropping `sudo`.

Second, your build is stalling because you run `psql` without any argument. This would wait for your interactive input to execute PostgreSQL commands, which never comes in the CI setting. You need to execute commands with `-c` or another means; e.g., `psql -c "select version();"`.

Third, when using `travis_wait`, the command should not be quoted (instead, `travis_wait 20 mvn clean install`). But I don’t think you’ll need that here.

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/amcap1712/32/4627_2.png) [@amCap1712](https://travis-ci.community/u/amCap1712)\
**Post date:** [March 13, 2020, 5:01pm UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564/5 "2020-03-13T17:01:56Z")

</div>

@BanzaiMan I tried without `sudo` and get permission error. Please see [https://travis-ci.org/github/amCap1712/pljava/builds/662045093](https://travis-ci.org/github/amCap1712/pljava/builds/662045093) . Can instruct me how to fix `$PATH or $JAVA_HOME` variables?

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [March 13, 2020, 5:56pm UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564/6 "2020-03-13T17:56:38Z")

</div>

Your process appears to be trying to write to system directories. I don’t think this is a good idea, and letting `root` do the job may not render your CI process to succeed, either. I suggest running [debug builds](https://docs.travis-ci.com/user/running-build-in-debug-mode/#enabling-debug-mode) to get a better understanding of your own requirements.

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/amcap1712/32/4627_2.png) [@amCap1712](https://travis-ci.community/u/amCap1712)\
**Post date:** [March 13, 2020, 6:00pm UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564/7 "2020-03-13T18:00:13Z")

</div>

@BanzaiMan I need to install a jar file to postgresql directory. Even during normal installation on a PC, root privileges are needed to do this task. The other option would be to install PostgreSQL in user’s directory instead of system. Is that possible or a viable option ?

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [March 13, 2020, 7:19pm UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564/8 "2020-03-13T19:19:53Z")

</div>

I am afraid I am unable to advise you on that, since I lack the expertise required. I suggest running the debug build (the feature is already turned on for this repo) to understand the requirements and the possible solutions.

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/amcap1712/32/4627_2.png) [@amCap1712](https://travis-ci.community/u/amCap1712)\
**Post date:** [March 14, 2020, 4:56am UTC](https://travis-ci.community/t/java-lang-unsupportedclassversionerror/7564/9 "2020-03-14T04:56:25Z")

</div>

Thanks @BanzaiMan, I will do that. Can you assist me further @Montana?
