i am currently developing an application on my Windows laptop however I also need it to run on a Mac. Is there a way to either convert my project to .dmg or .app or create a mac build striaght from Windows Eclipse?
I would very much rather not have to install Eclipse on the Mac machine just for this as it is a one time thing. Any Suggestions?
In my experiences you need a Mac to create anything for the Mac/iOS platform. So I guess you need a mac to create a dmg file.
Here is a post that says how this can be accomplished.
Of course you can just run the jar from the command line.
run on any Java virtual machine. It does not matter if you run it on a mac or pc, that's the whole idea with java
Any simple way of creating a dmg file will probably require a Mac, however you don't need to do that; after all, you don't create an exe when you run a Java program on Windows either. Instead export it as a jar file and it should work on both systems (provided a Java Runtime Environment is installed and is set to run jar filed).
If you insist on creating a dmg, check this question which discusses creating them on Windows.
Related
Recently I developed a jar file with JavaFX. Now my problem is how to convert it into an executable so it can install and run on other systems which do not have any JDK installed.
Also, when the client system starts from shutdown or hibernate I'd like the executable to run automatically.
I searched a lot on Google and I found content on the internet, but I did not find how I can achieve this.
how I can convert it into exec with the install so it can install into other systems which do not have any JDK on that system
You always need the JRE to run the jar file, there's no way around that. However, since the assumption that almost all systems would have the JRE installed is no longer correct, the normal thing these days is to bundle the entire JRE with the installer and use launch4j to create an exe file.
and another thing I want is that when client system start from shutdown or hibernate exec should run automatically.
You can't do this at the Java level, so it depends what OS you're running on. On windows you could use sc.exe to create a windows service from the executable, or you could just put it in the relevant user's startup folder.
I am not sure if this is possible, I wanted to run a Windows exe application from the command line from my java program - something like
Process process = Runtime.getRunTime().exec("myapp.exe --params");
The catch is that I would like to run the java application which calls the exe from within an OS X or Linux environment.
I was wondering if anyone has done this or has any suggestions on how it could be done? Thanks
Edit: thanks for responding. I did want to add that I would probably not want to use wine to run the exe and would probably want to create some type of wrapper around the exe file to call functions from the dll directly from java. I haven't done this before and was wondering if any pointers on this.
exe files are have a specific, Windows-only format called Portable Executable (PE). It's not compatible with the format Linux uses for executable files, not to mention differences in system calls between the two systems.
You can't just run an exe file on Linux, regardless of whether it's being run from Java.
If you really need it to work, you have two options:
Use a Windows compatability layer for Linux in the form of WINE (or similar tools)
Recompile your exe for Linux
I made a little minesweeper game and I want to send it to a friend so he can test it out. The problem(probably) is that he isn't able to run it because he doesn't have Java for programmers(JDK) installed on his computer. How is it possible to export a program that will work on other computers without having to download any other files**(other than JRE)**?
EDIT: I did read about converting the JAR to EXE but I couldn't find anything that would do it.
EDIT2: Download here the JAR file(it's only supposed to open a blank window). I tested it on two computers with JDK installed and it worked, whilst on two others without JDK(one with the newest JRE) it couldn't start. This is the error:
.
There is no way to "not have to download any other files" - your friend must minimally have some Java Runtime Environment (or just "Java") installed in order to run Java programs.
If your friend has Java installed, you can package your application as a fat JAR so that he only needs your JAR to run your application (depending on the application - but I think yours should be fine).
There are tools available, google "java windows executable" and you will find e.g.
Convert Java to EXE
http://jsmooth.sourceforge.net/
Or already on SO
How can I create a Windows .exe (standalone executable) using Java/Eclipse?
Java Web Start is ideal for this, as it can enable the user to install required components on supported platforms. There's a simple example here.
Not possible, a JRE (Java Runtime Environment) is the least that must be present.
If that is you can just export your program as jar specifying the main class in its manifest. Your friend should if a JRE is installed be able to run the jar file directly.
You could send your friend the compiled binary of your game. In that scenario, your friend will only need to have the Java Runtime Environment installed in order to play your game.
Make executable JAR from it, your friend will still need JRE.
I have created an project and need to distribute it over Windows. I need to create an exe for it I already know that there is a lot of tools like:
JSmooth
Launch4J
Executor
Advanced Installer etc.
The installer windows are done in Java itself. Means like the selecting locations, licensing etc. the only thing I need is to create an exe that should open this jar. Is that possible in Linux?
For a Java app. with a GUI, Java Web Start is the best option. It is supplied and maintained by the maker of the JRE, and therefore works on Windows, *nix and Mac.
I do understand the need for an .exe on Windows and I've used JSmooth before.
I would just make a shell script which launches the program. I think a shell script is fine for Linux: icons aren't built into the executable and you can't discover the location of a usable JVM automatically.
I made a Java application which I would like to distribute on Windows, OSX and Linux without distributing a jar file. I used the great Windows exe wrapper http://launch4j.sourceforge.net/ to create an .exe file complete with my icon that won't scare Windows users.
Are there similar wrappers that I can use for OSX/Unix? An important consideration is that I would like to have my own icon on the executable (especially for mac users).
Thanks!
Yes, on Mac OS X there is a program called Jar Bundler that is installed when you install the free (assuming that you already own a copy of Mac OS X) Xcode Developer Tools that allows you to bundle a JAR file inside a native Mac OS X "*.app" application bundle with a nice and shiny icon just like other apps.
Update
The JAR bundler doesn't exist on later versions of OS X. As a workaround, you can manually create an OS X project that invokes Java. Or, there are a variety of build system extensions that do a similar thing; for example, the gradle-macappbundle plugin for Gradle will create such a wrapper app.
JarBundler is obsolete, but there is a (better) official replacement: the javapackager tool.
For OSX, A simple, well explained, step by step tutorial on how to create a DMG from java is here: http://centerkey.com/mac/java/ . For other platforms, you just need to modify the example by using the proper switches in javapackager.
If you do not have a Mac to build this on (or want to integrate it into an existing build chain), you might want to have a look at the OS X Application Bundle Plugin for Maven.
This will (if run on Linux or Windows) create a zip that will unzip as a proper Mac application. If you run Maven on a Mac, it can also make a DMG.
You can also package your application with the JarBundler Ant task:
http://informagen.com/JarBundler
<jarbundler dir="release"
name="MyApp"
mainclass="org.foo.myapp.Main"
jar="myapp.jar" />
Github user Jorl17 made an excellent Python script called jar2app that does this with one simple command. It even lets you customize the app icon.
https://github.com/Jorl17/jar2app
Just install it, follow the instructions, and you get the .app file.