PulsePanda
PulsePanda

Reputation: 1856

Opening a .jar in Ubuntu

While making a game, i moved from programming in windows to ubuntu for better usability. that aside, when in windows, using Desktop d = Desktop.getDesktop(); and using d.open(new File("file dir.jar"); and it worked in windows. but, when using ubuntu, it opens the jar in an archive manager. so my question is, how would i open the .jar to be executed? Any help would be great! thanks in advance!

Edit: it may be possible i installed java wrong... but i did it the way i found on google. if that is the case, any correction would be great :D

Upvotes: 3

Views: 2493

Answers (2)

Jiri Kremser
Jiri Kremser

Reputation: 12847

I see two ways:

1) add the jar you want to run to the program classpath and run it's main method.

2) using Runtime.exec() you can run anything you want, but you may lose platform independence

Upvotes: 3

Barnaby Jones
Barnaby Jones

Reputation: 11

The archive manager is set as the default program to open .jar files. You will have to change it in Ubuntu's settings for default programs. You can right-click on the file you want to open and select to open it with your installed Java runtime environment, in the meantime.

Upvotes: 1

Related Questions