Wednesday, 5 October 2011

Launch Java Jar file or package in GNOME 3.x/openSUSE 11.4/Linux/Unix

Reactions: 


I was tired of running java jar files from gnome-terminal.I thought of a work around which i use in windows which involves running the "jar" using a ".bat" file


Step 1:-
I create a new file with extension ".sh"(Shell Script)
Step 2:-
I type in the command "java -jar <filename>.jar"
Step 3:-
I change the permission of ".sh" file and make it an executable
It can be done through terminal by executing "sudo chmod 777 <filename>.sh" (Or)
By right clicking on the ".sh" file and clicking on "properties" and changing the permissions and making the file an executable in Permissions tab
Step 4:-
You can double click on the ".sh" file now and run the required jar.
you must place the jar in the same folder as jar ,else you may need to specify folder path before "jar" name in the ".sh" file.You can edit the ".sh" file using "gedit" and change the jar file name as you please and run various jar files.

NOTE:-
If you want to keep the window open after jar execution to read  output from the execution of the jar then add a line {read -n 1 -p "Press any key to continue"} after the "jar" command and after double clicking the ".sh" file click on  "Run in terminal" as demonstrated below


No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...