My application won't open for Mac OS users - java

Recently, I have created my first public Java application, which opens a simple GUI. I have tested it on my Windows PC, but someone reported that the file does not open on their Mac OS.
Since I do not have anything running a Mac OS to test it, I'd need your help to tell me if there are differences when building the JAR file...
Because for all the people with Windows, it does work.
Is it something while building the JAR file? Or some part of the code would be different for Mac OS?
Thanks!

Jar files are designed to run on any OS that has a JVM of a compatible version installed. Some jar files, however, may have be compiled from Java code that used OS-specific code (say talking to Windows registries), so testing it on other OS's is wise.
Original post by Kathy Van Stone can be found here.

It ended up it was a security error, fixed by them with tips from the Apple.com page (here)
Thanks!

Related

Running Windows-Compatible .jar files on Linux?

Our CE project includes a .jar file which is written for Windows only for some reason. Unfortunately, I do all my coding related projects on Ubuntu and I'm really not willing to install VS on windows and start over on a new environment and lose a lot of efficiency.
The jar file requires some other files to work but the directory formats differ in Linux so I'm getting errors of it not finding the files when I try to open it from Linux.
I've already asked for the source code or a more compatible version but the TA's aren't really cooperative in my case.
Is there any way I could circumvent this problem and fix the incompatible directory formats issue(For example by running through wine)?
Edit: I tried decompiling the jar, but it wasn't fully successful and some of the files came out corrupted.
Because the original maintainers didn't think that this JAR would be run on other OSes, you're stuck placating their arbitrary requirement. You're going to want to use a VM (Wine isn't an emulator and you're going to run into significant pain using it and Java to run a JAR) to set this up and execute their JAR.
Once you get a hold of the source, you can build a new JAR which asks the OS which file separator to use instead of allowing the code to assume Windows. Or use NIO.

Java on OS X: "open" command won't run if .app package contains a JVM bundle

I'm trying to create a self-contained Mac app from a Java application. I've set up the .app directory, configured the Info.plist file, baked in dependencies as well as a Java runtime. I am successfully able to open the .app and launch the program and everything works except for one peculiar piece of code:
ProcessBuilder pb = new ProcessBuilder("open", "/Applications/TextEdit.app");
pb.start();
When I launch the .app, this code does not seem to run or at least do anything. If I open the package contents and launch the .jar, it runs fine. I managed to narrow it down to happen only when the .app contains a Java runtime bundle. Since running a .jar uses the system's Java and running the .app uses the bundled Java, this has got to be the reason I'm struggling.
The version of my Mac's installed Java JDK should be 1.8.0_77.
The bundled version should be 1.8.0_74. I grabbed it from the Moneydance application as I used it for reference when making my .app.
Any help is very appreciated as this should be the final step to release it. I created this question to be more specific than my other question here.
So I'll answer this myself as the issue was somewhat on my side.
The bundled JVM I was using (that I had copied from the Moneydance application) was the culprit. I suspect that the creators of Moneydance might have stripped their runtime bundle of features their app doesn't use in order to reduce the file size. Whatever the reason, my issue was fixed by creating my own bundle.
I did so by copying /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk to MyApp.app/Contents/PlugIns/. After that I edited the Info.plist key called JVMRuntime to use the entry jdk1.8.0_77.jdk. My app now uses this JDK instead of the bundle I previously had, and open now works as it should.
Apologies for not doing my homework, but thank you to the people helping. I found the issue while writing reproduction steps, so I might not have found it without you. I guess all I can say to those who might experience something similar is to check your JVM bundle.

How to make installer for Mac that detects Java version and installs if necessary

I've searched for this answer and I find things that are similar for Windows, but not for Mac. I have an old program that is used on Windows, but not Macs yet. I did not write it, but I have decompiled it to get the code. It looks like it shouldn't be that hard to make it work on Mac, but I want to make a nice installer so my users will want to try it. I have only recently gotten back into the programming game, so I am learning.
I have been investigating how to make a Windows installer that detects the Java version and then installs the correct one if necessary. Is there such a thing for a Mac installer? I have never worked on a Mac so I do not know how its guts work. I have a friend with a Mac who is willing to beta-test for me. I have one lib file that the program needs, plus an icon file. The lib file may need to be changed in the future. It's just a text file. So I would like the icon and the lib file to be part of the package.
I've seen that there is a Java app bundler for Mac, but it's not obvious that it a) checks the Java version and installs the right one or b) that I can include other files in the bundle.
I appreciate any guidance you can give me.

Exporting a program in Eclipse that works for people not familiar with Java programming

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.

generated jar file problem switching Windows/Linux OS

I encountered a strange situation and I'm struggling myself, trying to understand which is the problem.
I developed a Java application under Eclipse using Swing and jdbc.
I exported an executable jar file, created using Eclipse under Windows.
When I execute the exported file under Linux, everything is working fine, (both the gui and the database access) except that the JDialogs that sometimes are displayed, are not showing anymore in Linux.
If I generate the jar again, under Linux, (without modifying anything in the source code) JDialogs begin to work again.
What's the reason for this?
It seems that the problem isn't related to my source code, so do I have always to generate again an executable jar for every different operating system?
And again, if it is a problem related to the jar building process, why the only problem occurs with JDialogs?
I hope to be clear
thanks in advance to all
Of course you don't have to build on every platform. The idea is to make it once, run everywhere. Are you using the same versions of JDK/JRE on the Windows and Linux machines? Versions of other tools, e.g. Eclipse, Ant?
There are some Components in java swing that have bugs and may not be platform independant.
Perhaps JDialog is one of those bugs.

Categories