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
Related
I have already asked this and was heavily downvoted. Unfortunately, I still can't solve it. I don't know what I do, but sooner or later I loose an ability to run java applets and java web start applications in all browsers.
Here is an example what is happening.
I am opening page with applets http://csis.pace.edu/~bergin/Java/applets.htm and getting the following picture:
with signs plugins were blocked. I am trying to unblock
which causes another dialog
after OK I have another
next
if clicked
And so on.
Applet doesn't run.
After dancing with PATHes, Java updates and so one, once I can have applet run. But sooner or later I will stuck in this position again.
I would like to know, is it possible to exclude this situation in principle?
I mean I don't want to disable security at all, but I mean that in case my explicit permission everything should run. Is it possible to do that?
UPDATE
First of all, I don't understand, why can't I run applet on outdated java if I want?
I am a human and robots should obey me! :)
Suppose I wish to debug my applet on old version of java, why not?
Second, there is no information about what version it thinks I have and what version it wants?
Without this information it is possible that there is just a bug in version detection mechanism.
I have multiple versions of Java in Program Files since I am a Java developer. Then how can I know which one it uses?
UPDATE 2
I have updated my Java from 1.8.0_20 to 1.8.0_25 and now situation have changed, but applets are sill impossible to run.
The proof I have "latest" java:
The proof I have added the site above to exclusions list:
The effect of applet run:
(applet not runs)
Clicking details result:
(no any details in fact)
So, what to do?
UPDATE 3
This site is not working: http://ssd.jpl.nasa.gov/sbdb.cgi?sstr=2012VP113;orb=1;cov=0;log=0;cad=0#orb
(show orbit diagram)
Reloading/restarting browser does not help.
I looked at your html source and realized you're using the .class file directly instead of wrapping it in a jar file. This is what you have:
<applet code="GSort.class" width=700 height=400>
I think applets no longer work when using .class files directly due to new security requirements. They have to be wrapped in jar files because you need to add some security settings to the meta-inf folder of the jar file. Here is how oracle recommends deploying an applet:
https://docs.oracle.com/javase/tutorial/deployment/applet/deployingApplet.html
Edit:
I tried again with adding the site url to the Java security exception list and this time I got it to work! It looks like chrome stays in memory after exiting so changing Java security doesn't affect it unless you shut down chrome completely and restart it. Easiest way is to use Internet Explorer. Try it with Internet Explorer and it should work (assuming that you still have the site added under java security exception list).
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.
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).
I continue to get out of date message when trying to view an applet. The applet checker informs me that I have the correct version. I have the security settings correct but still no joy. When trying to go through the update it stops TO inform me that I have a later version already installed, which is correct. On a Mac OS 10.9 I could show you the screen shot but don't have the points. Bugger
Thanks for those who have replied and I'll try to elaborate further.
JavaApplets do run from the java web site. The creation of my own applets don't run. I have done some research and it would seem that under version 8 all JApplets must be signed. This would explain the message I receive. Also the link below may explain what the problem is. Sorry but I don't have the 10 points yet to be able to send a screen shot.
Again runnin the update (version7 downloads) stops to inform me that I have a later version installed (version 8). So you can see that things arn't perfect
![][1]
https://weblogs.java.net/blog/cayhorstmann/archive/2014/01/16/still-using-applets-sign-them-or-else
I've made a cool processing project that I would like to embed on the web; however, it uses 3rd party Java libraries to access an sqlite database. For this reason, the normal export-to-javascript which has worked well for me in the past is just not capable enough here. How can I make my Processing project into a Java applet that will allow it to be run remotely?
This depends upon what version of Processing you are using...
It was only in the final move to 2.0 that they got rid of the 'Export to Applet' option, so if you can make do with a 2.x-beta version, you're golden.
Of course, that's just through the PDE - so failing the ability to move to an earlier version, the library itself should be able to handle it still, from a different IDE, say Eclipse or NetBeans...
I guess the other option would be to see if you can port your library to a JavaScript library ?