I wrote the Swing program in Java 8. It, of course, does not run on machines which have Java 7 on them.
Is there a way to prompt the user, when he or she tries to run the .jar file, that Java 8 is required to run the program, preferably, by showing the dialog window with this prompt.
Create a new java 7 file that checks the users java version using System.getProperty("java.version") and then if it comes back as 8 then the java 7 file can start the java 8 file, if not it can send out a dialog box telling the user to upgrade.
If I remeber correctly, Launch4J could check for the correct JRE and would probably show some error message if the JRE could not be found. However, I do not know whether it works with Java 8.
This would also only work for Windows though.
I don't like the idea of a 2nd "launcher" jar/class that's written/compatible with a lower version of Java. That means that I have to keep this old version around indefinitely, which may be problematic since:
I need to know how old a version the launcher jar must be to cover all potential users.
I now need to support 2 versions of Java for my builds.
The old version may be insecure, and possibly EOL, with no hope of patches/fixes.
Java started embedding expiration dates in the version.
Consider launching your app via Java Web Start. This works on all platforms (I believe), and will handle the version checking for you.
Another alternative is to write a wrapper script (not written in Java) that launches your app. It could check for the presence and value of an environment variable (perhaps JAVA_HOME).
Related
Recently I switched to java 1.8, however this started to cause me troubles, as users that have older versions are unable to start my app. Is there any common method to deal with it, ie tell the user that his jre is outdated for the app and somehow direct it to the required one's download page?
if(!System.getProperty("java.version").startsWith("1.8")) {
// open website
}
How do you open a website? Check in this question.
However, this is code for it. This might not be it what you are looking for
Change compiler level to earlier version in your IDE, this way you can compile your code so that it can be understood by earlier version.
However, if you are using java 8 specific features such as lambdas, this will not work.
Problem with checking version in your program is that for that program to run, they need to have java 8 already.
Only way this could be solved is, running your prgram through a batch file or shell script
TL;DR: Apple has dropped native feature support in Java. Especially touchpad gestures are not working any longer. I wrote a library that does the job using JNI. Take a look at my answer below.
I'm searching for about hours to make the Apple Java Extensions work on JDK 7 or 8. I have been trying all I can think of. All threads on the internet about this simply blame the JDK for this. I think this should be solvable, because it worked in JDK 6. For clarity: I can make it work in JDK 6, but I don't want this legacy dependency, because not everybody that will use my application has JDK 6 or knows how to install it, let's say. The goal is to make a double-clickable JAR file that will run as expected with the OS X features (menu bar, gestures, about handler, etc...) with every version of Java installed (greater than JDK 6).
Since the developer preview release of OS X El Capitan, it became impossible for 99% of average computer users to install Java 6, so this was no longer an option for me. I finally decided to write a native library that will inform Java about gestures through JNI. The project works great and is hosted on GitHub.
Take a look at it here:
https://github.com/mcourteaux/MultiTouch-Gestures-Java
I just happened to run across your question and noted that it has not been answered yet. I have a Java program that I have been developing on the Mac, and noted that when I ran it under Java 7, the menu bar, Preferences, Quit and About all worked fine using rt. jar in the program's libraries folder and using a MacAppMenuHandler class that I wrote to provide functionality for those items.
However, when I switched to Java 8, they no longer worked. I'm not sure what the issue is though reading other web sites today suggest a "permissions" issue in Java 8 regarding these files.
However, I solved the problem by copying the rt. jar from Java 7 into the program's libraries, and it has continued to work for me while continuing to develop under Java 8.
I suggest this as one possible solution to the problem.
Hope this helps.
Go on your project Properties and select the Java Build Path Libraries, your JRE System Library should have an Access rules field like the one displayed in the image
Hit the Edit button and add an access rule to allow access to the com.apple.eawt package.
I had the same problem with "pinch to zoom" - it works in java 6 but not 7 or 8. I came across this bug in the jdk which seems to be responsible. It says it is fixed in Java 9.
Java is no longer installed by default on OS X, but fortunately if a user tries to launch a Java app, they receive the following message:
I really like this, as is clearly explains that Java is required and provides a one-click way to install it. It's simple and painless for end users.
However, this prompts to install Java SE 6 rather than Java SE 7, which has been out for some time. This even happens on OS 10.9.1, the latest version as of this writing. I'm considering making my app require Java SE 7, but I want to ensure that users will be downloading the proper version (I'm aware I can bundle the JRE, but I would prefer not to add it since it would quadruple the app size). Ideally, I'd like for the dialog box shown above to continue to be shown, but instead of downloading Java SE 6, it downloads Java SE 7.
I tried changing the JVMVersion key in the Info.plist file of my application to 1.7+, but that didn't make any difference and it still prompted to download Java SE 6 (which if it actually did require it, would result in an incompatibility).
So is there a way that I can get OS X to prompt the user to download Java 7 when they launch my app? To be clear, I want this to be something on the user side. I know that I can install Java, but I want it so that it is as painless as possible to the end user.
There is no way to automatically download Java 7 on OS X. This is by design. When you deploy an OS X application, you are expected to put everything that is required for the app to launching into the app bundle — inclusive of the JRE or JDK if you need it. If you find that the size of the JRE or JDK is unacceptable, you can prune out any components you don't need (JavaFX, AWT, JObjC, etc).
This is the most painless user experience you can offer. Download, double-click, and go.
I'm working on a little Java app and I'm currently putting the installer together. This checks for perquisites, such as Java being installed, and prompts the user to download anything that's required.
I need to set a requirement for the minimum Java version I support (I'm building with 7). Is there a simple way I can detect what this would be? So if I'm using any classes etc. not available in earlier versions. BTW I'm using IntelliJ.
I'm not sure if the entire 'system tray' complicates things, but..
For deploying Java desktop apps., the best option is usually to install the app. using Java Web Start. JWS works on Windows, OS X & *nix.
The best way to deploy a JWS app. or applet is to use the Deployment Toolkit Script. (That script will do the 'version checking').
I have been googling on this but I can't find the answer.
Can anyone tell me if you can put a Java application on the windows 8 start screen?
According to java.com
When will Java be supported in Windows 8? Windows 8 is officially
supported with the release of Java 7 Update 10. Java will only be
supported in Desktop screen. Java will not run in the Start screen.
I am not sure how to interpret this since I do not know the startscreen of Windows 8 and they talk about internet explorer 10 on the same page which makes me think they may only be talking about the browser.
Basically I want to have a tile to act like a classic windows icon. Is this the way it works and is this the way you can run a java application? Or do you need to go to the desktop interface first?
No. You can't.
All the apps on the Windows 8 start screen are the apps downloaded from the Windows Store.
All the other Java applications that you develop will run in the desktop environment, but not in the start screen.
As per this source, you can look forward towards creating apps for Windows Store using Java and then you can maybe think of putting a Java application on the Windows start screen.
You cannot put directly a Java application in the start screen in windows 8 (just as you couldn't create shortcut icons on the Desktop in Windows 7), however notice this is rarely what you want with a Windows desktop application.
Most of the times you will want to wrap your Java desktop application with a windows installer which will put the start screen icon on windows 8.
Your Java code will then be launched by the installer executable which might do some house cleaning jobs like checking what compatible version of Java is installed in the computer and if required install a newer one.