开发者

exporting java jar help from Eclipse

开发者 https://www.devze.com 2023-03-20 15:43 出处:网络
so I have a project that only has one class Main: public class Main{ public static void main(String[] args) {

so I have a project that only has one class Main:

public class Main{

    public static void main(String[] args) {

        System.out.println("asdf");
        System.out.println(args[0]);
        System.out.println(Integer.parseInt(args[1]));

    }
}

so I tried to export this as a standalone jar...here's what I did

  1. created a run configuration for the project...the run configuration runs properly from eclipse...it prints the arguments just fine...
  2. right click on the project, selected export
  3. choose the runnable jar file option
  4. selected my previously created run configuration as the run configuration, chose export destination press finish, etc

but then when I run the program from the commandl开发者_高级运维ine:

Main.jar "testtest" 123

nothing came up.....it didn't print out the arguments....nor did it print out the "asdf" I specified in the main() function...

what did I do wrong?


Run java -jar Main.jar "testtest" 123 ?


I think you are getting wrong what exporting as a runnable jar means: This does not create an executable file. It just creates an archived file with all your compiled classes and some special meta information about which class to run when invoked with java -jar JARNAME.

Note that this also means all users of your program still need to have a java runtime installed.

0

精彩评论

暂无评论...
验证码 换一张
取 消