- Converting a .jar into a Mac OS X app [closed]
- Convert Java application to Mac OS X app
- 8 Answers 8
- Use the Apple Java Extensions and its Guide
- Other references:
- commands
- Mac How to modify a java .jar file?
- dudleybrooks
- jiminaus
- mufflon
- dudleybrooks
- notjustjay
- chown33
- notjustjay
- pilotError
- dudleybrooks
- chown33
- Edit jar mac os
- Option 1 — manual download and install on any OS
- Using the Java-based installer
- Option 2 — easy install on some flavors of *nix
Converting a .jar into a Mac OS X app [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago .
I’m trying to create a java-based GUI for both Mac and windows. So far, I’ve been able to create an executable .jar file that runs on Windows.
The issue I’m running into is running that .jar on Mac. When I double-click to run, it says I should use -XstartOnFirstThread option to run the .jar . So, I’ve created a shell script that simply opens it with the following line of code:
This runs the program well, but it’s not a solution that is easily distributable. So, I’m trying to bundle the .jar into a Mac app. So far, everything I’ve tried results in the same error code:
Here’s what I’ve tried so far:
JarBundler (link here): same issue
Java Tutorial: tried following this tutorial, but appbundler seems not to exist anymore (at least I can’t find it on my mac and I can’t find it on Java’s website) and most of the links to other softwares that are on this page are dead.
AppBundler ant task (link here): Couldn’t quite firgure out how to use this.
Eclipse OS-X App Bundler: same issue.
changing permissions on the executable JavaApplicationStub within the app: same issue
bundling the app on my own from scratch: same issue.
I’m pretty much out of ideas at this point, is there anything I am missing?
EDIT: The .jar file that I’m using was created by Eclipse’s «create runnable JAR file» export option. Not sure if this makes a different or not.
Источник
Convert Java application to Mac OS X app
Is there a way to convert a Java application into a Mac OS X executable app?
I use NetBeans to develop in Java, and I’d like to «pack» the «dist» folder into an app (just for convenience)
8 Answers 8
Use the Apple Java Extensions and its Guide
The Apple Java Extensions contains a very complete development guide with information on the deployment of Java applications on Mac OS X and the production of application bundles. It also introduces other aspects of the Apple Java Extensions, like the support for integration with the standard Mac OS X UI.
Other references:
There is a library that let’s you package your Java app
Packr: https://github.com/libgdx/packr
Packages your JAR, assets and a JVM for distribution on Windows (ZIP), Linux (ZIP) and Mac OS X (.app), adding a native executable file to make it appear like the app is a native app.
It can even minimize the JRE for you.
Packr is a great tool, but at the time I found that I wanted something «easier to use», so jar2app was born. I know this is an old question but perhaps other people might find this program easier to use than other alternatives. If they don’t, there’s a direct reference in the FAQ to other alternatives (such as Packr).
You can use javapackager tool to build the application and wrap it in into an installer, the following commands show how to convert a jar file into a bundle file:
commands
To change the application icon and more info MacJava.
Since some of the links in the accepted answer are no longer available or suitable in 2020, 8 years from the question was asked, I would like to share my findings that I confirmed working today.
There is a tool, javapackager , shipped with java, can package java application on Windows, Linux, macOS for you.
For packaging a mac application, I used this command:
And this is the explanation:
After the command is executed, there will be some files and directories created in dist , where I want the package be, and one of the directories is bundles . The application is put in there.
Since I just built an internal tool, there is no need to sign and packaged without other production ready options. You can refer to the official manual for help.
Hope this help others who do not know how to package an application on macOS in 2020, just like me.
As of JDK14 there is also 📦jpackage (JEP-392), at the time of writing still in the incubating phase, probably not production ready, but already does the job.
Example usage that worked with an swt app (assumes all the required jar files reside in the files folder; you can also provide a custom resource folder with —resource-dir ):
For the full option list use:
WARNING: It’s probably debatable whether it’s a bug or not, and maybe it will be addressed in a future release, but in the current version, if you specify the input folder as -i . , and do not provide a custom destination with —dest then jpackage will bundle everything in the current folder. including the bundle it just created, i.e. it goes recursive on itself since . is both the input folder and the output 😀 .
So none of these options worked for me (maybe because I am running OS X 10.15, maybe because most of these projects are years old, who knows). Installing Catalina made the existing app I had built around the Java app no longer work.
Ultimately, this post helped: Just use Automator to run a script that runs the java command to launch the jar. I wanted to make an app to launch Colossus, a Java version of the old Avalon Hill board game Titan. I wrote a shell script that looks like: java -Xmx256m -jar /my/path/to/the/game/Colossus.jar net.sf.colossus.appmain.Start and then created an automator application whose only action was «Run Shell Script» that launches that script. Works like a charm, no installing Ant, no command line apps requiring you to download java vms, and best of all it uses an Apple tool so will work with newer versions of OS X.
You can try this app , it bundles your jar file into Mac app
Edit: it’s easy to use , select the Jar file and an Icon. Here you can see the screen shoot.
Источник
Mac How to modify a java .jar file?
dudleybrooks
macrumors member
jiminaus
macrumors 65816
A .jar file is just a .zip file with a different extension (and some standard/predefined layout). You could use the standard zip and unzip programs in /usr/bin to change a .jar file, assuming it’s not signed.
«Changing a single line in a .jar file» doesn’t directly make sense in the context of .jar file. If you tell us exactly what you want to do with that .jar file, we might be able to tell you what Mac OS X tools/programs you can use and how.
mufflon
macrumors 6502
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; sv-se) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5)
There are really three phases: extraction, modification and assembling it back together.
Extracting is easy: right click and click unarchieve (afaik).
Modification: if it’s the manifest (whick class to run and so forth) then it’s easy, however the java files are compiled into .class files and will need disassembling before modification.
To piece everything together google the «jar» command for the terminal.
If it’s FOSS it’s better and easier to compile from source; if not then I don’t think it’s 100% legit.
dudleybrooks
macrumors member
I need to change a line in a .js file contained in the .jar file. But your reply clarifies my question:
I made this change many, many times under Windows (namely every time I downloaded an upgrade, which, of course, wiped out my previous change). The person who recommended the change also recommended an (un)archiver called IZArc, in which the whole process could be done from inside IZArc — open (unarchive) the .jar file, find the .js file, edit the line . and then clicking Quit would return everything to its archived state.
I understand that I can unarchive the .jar with any unarchiver and edit the .js with any text editor. I guess my worry is that, not being a programmer, I might do something harmful in re-archiving — not archive all the relevant files, or archive too many files, or something.
So my question is: Is there an archiver (hopefully in the OS) which will do all the above from within itself, so that I know that the final .jar contains exactly the files that it should contain? Or, failing that, what do I need to do to make sure that I have re-archived it properly? I realize that in this forum this is a complete newbie question.
notjustjay
macrumors 603
chown33
Moderator
Or use the ‘jar’ command, which is written expressly for this purpose, and maintains the correct ordering for manifests (which typically must reside as the first entry, or at most one of the first few).
I’m pretty sure the jar command is installed by default. This should continue to be true on 10.7 Lion, as well.
notjustjay
macrumors 603
Or use the ‘jar’ command, which is written expressly for this purpose, and maintains the correct ordering for manifests (which typically must reside as the first entry, or at most one of the first few).
I’m pretty sure the jar command is installed by default. This should continue to be true on 10.7 Lion, as well.
pilotError
macrumors 68020
Or you can use the jar command. The parameters are just like the command line zip utilities
$jar -xvf jarfile.jar ** Extracts the files
$jar -cvf jarfile.jar ** Create the new Jar file
dudleybrooks
macrumors member
chown33
Moderator
I don’t know of any tool that does everything. Frankly, this is the first time I’ve ever seen anyone ask how to edit a file within a jar on Mac OS, so I’m guessing there isn’t a big target market.
You can paste command-lines into Terminal, so just save the commands into a text file, then copy and paste away. No typing needed.
Here’s roughly what I would save in the text file:
You should obviously change the jarfile.jar to the actual jar file you have.
I’ve shown ## because those are the actual comment character for bash.
I’ve also shown an ‘open -e’ command with a pathname you will have to substitute. The open -e will open the named file in TextEdit.app. If you have another editor you prefer instead, you can tell ‘open’ to use it instead. Here’s the man page for the ‘open’ command:
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/open.1.html
Look at the -a and -b options in particular.
Finally, you can put other commands in there, such as a ‘cd someDir’ or whatever else you want.
You could probably write a ‘sed’ script to do the replacement, so you wouldn’t have to manually edit the file at all. Then you could make the whole thing into a shell script, wrap that into an AppleScript and save it as a droplet. Then in future, you simply drop your original app onto the AppleScript droplet and it would do all the changes automatically. You’d have to write and debug all that stuff, though, and it would probably take hours more time than just doing a copy/paste when the app gets updated.
If the change to the jar is something the vendor should provide, you should probably file a bug-report against the app. Because the cleanest fix is to not have to fix it yourself at all.
Источник
Edit jar mac os
Last Site Update: 03 September 2020 | Stable Version: 5.6.0
Java Runtime version 1.6 (aka Java 6) or later is required for jEdit 4.4 and later.
Java Runtime version 1.7 (aka Java 7) or later is required for jEdit 5.2 and later.
Java Runtime version 1.8 (aka Java 8) or later is required for jEdit 5.4 and later.
Java Runtime version 11 (aka Java 11) or later is required for jEdit 5.6 and later.
Before installing jEdit, make sure you have a compatible Java virtual machine; see the compatibility page for details.
Option 1 — manual download and install on any OS
Stable version: jEdit 5.6.0 Changes | |||
Download: | Java-based installer | 3.7 MiB | (For any operating system) |
Windows Installer | 4.8 MiB | ||
OS X package | 5.5 MiB | ||
Debian package | 4.9 MiB | ||
Slackware package | 4.9 MiB | ||
User’s guide | 0.6 MiB | (PDF with A4 paper, 149 pages) | |
User’s guide | 0.6 MiB | (PDF with US letter paper, 159 pages) | |
Source code | 2.5 MiB | ||
Daily Builds: jEdit 5.7pre1 (development trunk) Changes | |||
Download: | Daily Builds |
Note: the above links are not to the files themselves, but rather to pages where you can select a download mirror. Do not use your browser’s «Download Link» command on the above links.
Installation instructions are available for the following operating systems:
Using the Java-based installer
Option 2 — easy install on some flavors of *nix
- FreeBSD users can find install jEdit from the ports collection by running:
- Gentoo Linux users can install jEdit from the portage tree by running emerge jedit .
- To install jEdit via Debian Linux apt-get (this is also for any Debian based Distros like Ubuntu), add the following line to your /etc/apt/sources.list :
Then, just run apt-get update , followed by apt-get install jedit .
The repository is now also secured and signed. To verify the packages you have to install the public key with which the repository is signed. This can be done by invoking apt-key adv —keyserver keyserver.ubuntu.com —recv-keys E6A233DBE3AFBEFC
If you prefer manual installation of .deb files you can also download the Debian package manually.
Источник