Java Application main class not found on Ubuntu

前端 未结 1 851
悲哀的现实
悲哀的现实 2021-01-24 22:24

I am using the Gradle Application Plugin to distribute a Java Application for Windows and Ubuntu / Linux / Mac etc.

I tested this on Linux some weeks ago and it worked p

相关标签:
1条回答
  • 2021-01-24 22:37

    After spending hours trying different things, I finally found out what the problem is.

    Ubuntu (and Raspbian) use OpenJDK per default. The development for my application was done on Oracle Java 8.

    After installing the Oracle JDK on Ubuntu it worked on the first go.

    I don't know if this is an expected behavior. I have two questions:

    • Shouldn't OpenJDK have the same parameters when executing a Java file?
    • If not: Shouldn't Gradle support OpenJDK?

    To make my solution complete, I want to post some informations how you can install Oracle JDK 8 easily on Ubuntu (15.10):

    I used the webupd8 repository which provides an automated way of installing Java 8 on Ubuntu (this is also recommended by Ubuntu/Canonical).

    Our PPA supports Ubuntu 15.04, 14.10, 14.04 and 12.04 as well as Linux Mint 17.1, 17 and 13. Add the PPA and install Oracle Java 8 (the package provides both JDK8 and JRE8) using the following commands:

    sudo add-apt-repository ppa:webupd8team/java 
    sudo apt-get update sudo
    apt-get install oracle-java8-installer
    

    Tip: if you're behind a firewall / router that blocks some of the redirects required to download the Oracle Java archive, you can download the JDK tar.gz archive manually and place it under /var/cache/oracle-jdk8-installer - then, installing the "oracle-java8-installer" package will use the local archive instead of trying it to download it itself.

    Once installed, running "java -version" in a terminal should output something like this:

    andrei@andrei-desktop:~$ java -version
    java version "1.8.0_31"
    Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
    
    0 讨论(0)
提交回复
热议问题