I have a code snippet that is part of my eclipse plugin. When testing it in a runtime eclipse version (That means it is not packed into a jar afaik) it runs just fine.
However if I pack my plugin into a jar and then run the respective code snippet it results in a complete crash of eclipse without any error logs (I'm assuming that it even crashes the JVM).
I'm running this on Linux Mint.
According to this post the Desktop API is broken in older Java versions but it should be fixed in Java 8.
Has anyone an idea why this is still happening?
Although this is not an answer to the question why the Desktop API breaks down when used inside a jar file, I want to point out an alternative that I have found (thanks to #Holger) for my case (working with the eclipse APIs):
You can simply use PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(<YourURL>); in order to open the given URL in the system's default browser.
Related
I think this stackoverflow question already has my answer: IntelliJ runnable jar doesn`t work on other computers
The answer on this question states that most IDEs can autoinclude the needed java libraries to make the jar runnable on pc's without jdk. My question is, where in IntelliJ can I make sure that these libraries are included?
In my project java 15 jdk already shows as external library: link to screenshot
This is what my artifact settings look like: link maybe I need to change something here?
Edit: My question is this: The jar file IntelliJ produces works fine on my computer. On my friends computer excecuting the file gives an JNI error. He only has JRE on his computer and not JDK. I am assuming the problem has something to do with this. How can I make sure the jar file runs on computers without JDK and with JRE?
Your program can run without the jdk but it will need a jre -- the Java Virtual Machine is needed.
You can create this on Java 11 and above using jlink which creates a custom cut-down Java runtime, along with your code, that can be executed on a different computer. However, it will have to be the same architecture/operating system; you can't run the Windows JVM on macOS or vice-versa, for example. Your application code, in the .jar, will be the same on both though.
I have got a new version of a Java Swing Application (DMG file) that I want to test, but it keeps opening the Old version of the application, even though I have deleted the old application. It's like it's opening a cached version.
This is how I install the application:
Open DMG file.
Drag file to Application folder.
I only see this issue on OS X. On Windows it works fine.
I even tried running the jar file directly, and I see the same behaviour; it works on Windows but on Mac it shows the old version.
I tried the following but I saw the same behaviour:
Restarting the computer
Clearing/Deleting the Java cache (from
System Preference>Java>General>Temporary Internet Files>Settings>Delete Files...)
Logging as the Guest user on my mac.
Lastly, I have tried this on a different Mac and I do NOT see the issue. It seems like there is something specifically wrong with my OS X.
There was a copy of the old version in /Users/*/Library/Java/Extensions which was required by the Robot test automation framework.
Deleting it solved the issue.
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.
I've my JavaFX app that calls some JNI code, uses a preloader jar and is compiled using jdk 1.7.
Now when I run jar on another computer with JRE7, by:
Double clicking jar: it starts but cannot load the JNI code containing libraries and therefore gets stuck.
Running jar via terminal using "java -jar ": App runs completely normal!
Now if I install jdk on this machine,
it runs fine even with double click!
Can somebody tell me what is difference in these 3 cases?
Try to add logging to your program, so that you can figure out why your JAR file doesn't execute properly.
You should look into if your manifest file is correct - there is a classpath in there you might want to take a look at.
This may have something to do with the fact that JavaFX is not fully released with Java 1.7, but included more as a developer preview.
Also, JavaFX packaging and deployment is a little different than standard Java. There is a new utility called 'javafxpackager' that should be used when packaging JavaFX applications. Check out the documentation here: http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm
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.