Why doesn't my jar file run twice?

I am having problems running the double-click jar file (and open it with java SE), the jar only starts perfectly from the command line, the other banks that I created are launched with a double click.

I exported the jar file using the eclipse exporter, I used the runnable jar export and selected the correct main () class in the launch configuration

When I start the jar using java -jar myjar.jar, it starts, as expected, there will be no exceptions.

I am under linux / windows has the same problem that I do not see the point, because other jar files created by me in the same way, run without any problems.

Just for fun, I created a program ccontaining only

int main(void){
   system("java -jar myjar.jar");
   return 0;
}

When I double-clicked the compiled program c, my can opened!

Here is the MANIFEST

Manifest-Version: 1.0
Class-Path: . libs/commons-compress-1.10.jar libs/zip4j_1.3.2.jar libs/xz.jar libs/commons-io-2.4.jar libs/oat2dex.jar
Main-Class: deodex.Tester

Here is the method main: http://pastebin.com/M8Fhb4qW

package deodex;
import deodex.tools.Logger;
import deodex.ui.LangFrame;
import deodex.ui.Window;
public class Tester {
        public static void main(String args[]) {

        if (Cfg.isFirstLaunch()) {
                    Cfg.setCurrentLang(S.ENGLISH);
                    R.initResources();
                    @SuppressWarnings("unused")
                    LangFrame win = new LangFrame();


        } else {
            Cfg.readCfg();
            R.initResources();
            S.initTempFolders();
            Logger.logToStdIO("[test]" + Cfg.getCurrentLang());

                    @SuppressWarnings("unused")
                    Window win = new Window();



        }

    }
}

Thank you in advance


JFrame , JFrame, , , Windows, , , , , ... ? , JFram, terminal/cmd, , R Cfg , , .

Edit
, JDK Oracle JDk, ,

+4
2

, : , - JAR, , final File("lang/en.prop");, GUI JAVA SE, , , Cfg NullPointerException, , , PathUtils,
PathUtils.java

    public static String getExcutionPath(){
        String path = "";
        try {
            path =PathUtils.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println("Somthing went wrong couldn't detemine our current location !");
        }
        return path.substring(0, path.lastIndexOf("/"));
    }

Launch , , !

+1

Java SE Runtime. Java Java Oracle.

Linux PPA ppa:webupd8team/java oracle-java8-installer. , , , Ubuntu Unity XFCE, .

0

Source: https://habr.com/ru/post/1627443/


All Articles