Posts: 10
Joined: Tue May 29, 2018 2:26 pm

Create executable of java program

Fri Jun 01, 2018 4:59 pm

I have a java program on my Raspberry Pi that I am currently running using the BlueJ IDE. I would like to make the program executable by clicking on a file or icon on the Raspberry Pi desktop, and I am unsure how to do so. It looks like I can make a JAR file of the .class file, but would I be able to just click on it and have the program run?

User avatar
Posts: 41175
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Create executable of java program

Sat Jun 02, 2018 8:00 am

Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Posts: 10
Joined: Tue May 29, 2018 2:26 pm

Re: Create executable of java program

Mon Jun 04, 2018 12:27 pm

I can create the JAR file, but I cannot seem to figure out how to make it executable just by clicking on it. When I created the JAR file it was zipped, and when I extract it it makes a new file called META-INF, which is very similar to the myManifest file I made when trying to make the JAR file. So how do I make the zipped JAR file into a shortcut that I can run just by clicking on it?

Posts: 17995
Joined: Tue Jul 17, 2012 3:02 pm

Re: Create executable of java program

Tue Jun 05, 2018 3:43 am

What you can do is create a little shell script that in turn uses the usual "java" command to run your jar file.

This blog post describes this nicely: ... executable

The next problem is to create an icon for the Raspi's Window manager that runs that little script when you click it.

I don't use the Raspi desktop so I'm afraid I cannot help there. A search of this forum should find you something.
Memory in C++ is a leaky abstraction .

Posts: 24
Joined: Wed Mar 23, 2016 2:34 pm

Re: Create executable of java program

Wed Jul 11, 2018 5:08 pm

See my updated post below.
Last edited by PiBurner on Thu Apr 18, 2019 2:17 pm, edited 1 time in total.

Posts: 2
Joined: Tue Sep 11, 2018 11:21 am

Re: Create executable of java program

Wed Sep 12, 2018 12:43 pm

Easiest way (for me) to get an "runable Jar File" is with Eclipse (using Ant), under some more powerful machine (I tried running Eclipse over a RPI, much too slow). Under Eclipse, Right click over your package/class containing your "main" method, then choose "export" within the popup, then choose "runnable jarfile", then don't forget to tag "save as ant script" if you want to export it again after modification of your java project by double-clicking over the Ant script file (you'll have of course to specify a file name and a path to have it available and visible within your project (type F5 to refresh the Eclipse view if it doesn't appears). I normally get this way jarfiles that run just through double clicking on their file icon.

Posts: 1
Joined: Fri Sep 14, 2018 2:26 am

Re: Create executable of java program

Fri Sep 14, 2018 2:39 am

I've been using eclipse juno for this. Made an app just like Showbox for android , I used only java for this.
Now, I'm thinking of changing my main coding software for .java files. Any ideas where I would go?
Busy watching movies

Posts: 10
Joined: Mon Sep 17, 2018 7:43 am

Re: Create executable of java program

Thu Oct 04, 2018 8:07 am

I found the Apache Maven Assembly Plugin, which packs everything, the executable jar needs, into it, very handy. You just have to add the plugin in your pom.xml, and call maven with the goal "package". You can do this with an Eclipse runtime configuration, but of course as a separate process on a build server as well.

Homepage is here: ... index.html
Nice short description is here: (Chapter 2.2)
Regards, Balin.

Posts: 1
Joined: Fri Dec 28, 2018 4:21 pm

Re: Create executable of java program

Fri Dec 28, 2018 4:22 pm

java programming

Posts: 24
Joined: Wed Mar 23, 2016 2:34 pm

Re: Create executable of java program

Thu Apr 18, 2019 1:01 am

Assuming you have version 9 Stretch from April 2019 running on you pi:

Once you have the .jar file made, I now have an easier way to set an association that has some advantages:
To set association for java .jar files so you can double click on it and launch, do the following:

Click on the start raspberry and select Preferrences>Main Menu Editor
pick a the 'Other' menu location on left side
click on new item
type in name you want displayed (I used ' Java Start ')
for command, use ' /usr/bin/jexec %f ' (no quote marks or spaces at beginning or end)
do not click on Launch in Terminal
click on OK
new name used should show in list on right and checked to use
click OK to finish
right click on the jar file and select 'Open With'
expand the 'Other' category
click on the new item name
set check box for 'Set selected application as default action for this file type' at the bottom
click on OK and the jar file should launch.
double clicks on any jar file will now launch it.
Java Start (or whatever you named it) will show as an option when you right click the jar file, also.

To make a desktop shortcut:
Copy the file 'Java Start ' from /home/user/.local/share/applications that got made when you did the association above.
Paste it on the desktop
Open it with a text editor
Change the line /usr/bin/jexec %f to Exec=java -jar /home/user/Desktop/appName.jar, assuming the jar file is also on the desktop or change the path accordingly.
Change the Name=Java Start line to a name you want to show on the desktop shortcut.
Save the file.
Now you can double click on the shortcut to launch that app (jar file).

To make the app auto launch on boot-up:
copy the desktop shortcut to the /home/user/.config/autostart folder. You'll need admin rights (sudo) to make the copy.

You can email me at

Posts: 15
Joined: Mon May 20, 2019 8:14 am

Re: Create executable of java program

Mon May 20, 2019 12:25 pm

You should use JSmooth, it works like a charm.
I have used it in the past without nay trouble.

Return to “Java”