Mega524
Posts: 5
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
DougieLawson
Posts: 33020
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Create executable of java program

Sat Jun 02, 2018 8:00 am

Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Mega524
Posts: 5
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?

Heater
Posts: 9344
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: https://coderwall.com/p/ssuaxa/how-to-m ... 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.

PiBurner
Posts: 14
Joined: Wed Mar 23, 2016 2:34 pm

Re: Create executable of java program

Wed Jul 11, 2018 5:08 pm

Right click on the .jar file and select 'Open With'. In the command line box enter 'java -jar /[full path to the jar file]' (without the single quote) and check 'Set selected application as default action for this file type'.
I usually add the complete jar file name in the 'Application name' text box, also.

Return to “Java”

Who is online

Users browsing this forum: No registered users and 2 guests