Ferenc Dajka
Ferenc Dajka

Reputation: 1051

Start a jar with an other jar, and cmd argument

I hava a jar with a main file like this:

public class StartMesekocka3D {

    public static void main(String[] args) {
        try {
            Runtime.getRuntime().exec("java -Djava.library.path=\"bin\" -jar \"Mesekocka3D.jar\"");
        } catch (IOException ex) {
            Logger.getLogger(StartMesekocka3D.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

I'd like to start an other jar with a djava argument. If i double click on the jar (they are in the same folder of course), nothing happens, if i type java -jar Startmesekocka3D.jar it's starts the other jar, and works perfect. What should be the problem with double clicking?

Upvotes: 2

Views: 130

Answers (2)

Zakaria
Zakaria

Reputation: 15070

I don't think that double clicking will launch StartMesekocka3D. You have two solutions :

  • You can create a batch/shell file (easy solution).
  • You can follow this tutorial to create an executable jar. If you are using Netbeans, here is tutorial.

Upvotes: 1

Satya
Satya

Reputation: 8881

for creating an executable jar which can be started by dbl clicking, you need to define Main Class entry in manifest.mf and then jar it with the new manifest.mf

Upvotes: 0

Related Questions