kamikaze_pilot
kamikaze_pilot

Reputation: 14844

exporting java jar help from Eclipse

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 commandline:

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?

Upvotes: 0

Views: 157

Answers (2)

FRotthowe
FRotthowe

Reputation: 3662

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.

Upvotes: 1

Frederik
Frederik

Reputation: 45

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

Upvotes: 3

Related Questions