Starting Java Webstart App with older installed JRE Version - java

is there any chance to start a jnlp with jre 7_17 while jre 7_45 is the latest version installed on the system?
First i tried it by editing the jnlp file itself and changing the version from 1.5+ to 1.7.0_17. But this wasnt working. After some research, this could be a bug.
Then i tried to start the jnlp file by commandline and the javaws.exe from the bin path of the older jre version. But still the newer one is used.
Are there any chances to have many jres installed and open the different webstart apps with the version which is supported by the supplier ?
thanx
Marcus

You may not start the jnlp file itself with a specific java version - the one installed (and default in the webbrowser) is used to start the jnlp. However you can specify with which java version your application/applet is started afterwards. Here is a description:
"The version attribute refers, by default, to a platform version (specification version) of the Java(TM) Platform Standard Edition. Currently defined platform versions are 1.2, 1.3, 1.4, 1.5 and 1.6. (A platform version will not normally contain a micro version number; e.g., 1.4.2.)
Exact product versions (implementation versions) may also be specified. by including the href attribute. For example, 1.3.1_07, 1.4.2, or 1.5.0"
...
You may also use < java ...> instead of < j2se ...>
Furthermore if you have an jnlp based application it should work to manually specify the (full) path to your older java.

Related

Is JRE 1.7 able to run 1.8 jars?

I have two jars: CLI.jar and Some.jar; CLI.jar depends on Some.jar.
The major version of CLI.jar classes is 51 (Java 7)
The major version of Some.jar classes is 52(Java 8)
I run java -jar CLI.jar with JRE 1.7 on a host, it gave "Unsupported major.minor version 52.0" error.
I initially thought it was a JRE version issue, but when I switched to another host which also had JRE 1.7, I did not see this error and everything worked fine.
What did I miss here? I am a professional software developer and I know the basics and double checked the JRE version I am using.
JRE 1.7 is not able to run 1.8 class files (and, by extension, JARs that require 1.8 class files). The error you have encountered points that out quite well.
If another computer can run the same JAR file, its Java version is not 1.8. Note that multiple JREs can be installed on one machine.
TL;DR - No, Java byte code is not forward compatible, but it is backwards compatible.
A bit more details:
Generally, files compiled with later Java version can't be run on the earlier Java machines (e.g. classes compiled with Jdk 1.8 can't be run with Jdk 1.7).
However, this statement is false in the way around context. Any version of Jdk is inherently, and by design, backwards compatible1, which means, that Jdk 1.8 can run programs compiled with compiler from Jdk 1.7.
1There is a little catch here. It's rare, but sometimes, later Java versions deprecate and then finally remove some APIs, Frameworks, Libraries or etc. from the build. For example, JavaFX has been removed since Java 11. So, if this kind of situation arises, and you upgrade your Java, you'll just need to manually add missing (in this case - JavaFX) dependency.

JDK and JRE version confusion

I've been working with Java for a bit now and the JDK/JRE version has given me quite a bit of trouble lately. I am developing using the Intellij IDEA IDE and it of course uses the latest version of the JDK, 14. However when I attempt to execute software compiled with JDK 14 outside the IDE, I get an error that the JRE isn't new enough to run this software. So I updated Java on my computer and another machine and attempt to run again without any success. After some digging, I tweaked my machine to use the JRE included in the JDK 14 which is compatible.
However it is kind of odd that I had to do that, one would think that the latest version of java should of been enough to run applications made with the latest version of the JDK (14). Right now Java is version 8 build 251 and says there is no newer update available. If JDK 14 is out for a while now, why would they not update the version of Java they ship?
The problem is partially solved, as only the machine I am using for development is capable of executing the created applications. Other people I've sent them to have been unable to run them, despite having the latest version of java. Also it is a pain to get the latest JDK, especially when having limited experience on how to get rid of old versions, change path point to the latest version, get the right package (open/oracle JDK) and do that for windows and several distrubutions of linux. What is going on? Did I get Java from the wrong place and everyone else as well? Why are oracle doing this and why are there no java updates since clearly there exists a newer version?
Starting with Java-11, separate JRE does not exist anymore. In other words, if you are using Java-11 or above, you should care about JDK only.
You should uninstall JRE-8 from your machine and make sure your JDK-14 bin folder in the PATH variable. Some application even requires JAVA_HOME to work and therefore you should make sure that your system has an environment variable called JAVA_HOME and its value set to the root folder of JDK-14 (i.e. one level above your JDK bin).
Q: What should my clients do to run my application compiled on JDK-14?
Ans: Your clients must install JDK-14. Also, check this thread for some alternatives.
You're confusing how IntelliJ or JDK are used on the OS. IntelliJ, now, often comes with its JDK binaries (but even this can be configured, IntelliJ can be configured to use any JDK/JRE build you'll provide to it); however, if you run your Java application out of IntelliJ, most likely you're using Java installed locally on your OS, which might be referenced via your JAVA_HOME environment variable.
I'd suggest to:
Check java -version in your shell (and hence you'll see what JVM instance your OS spins up when you run a Java application);
Check where java (on Windows, or which - on Linux) in your shell, to see all the Java binaries available on your OS.
Try to uninstall Java SE Development Kit and Java JRE(if you have both in your machine) and reinstall both again, JDK and JRE both, I am sharing my google drive link where you can find the latest version of both JDK and JRE and when you are done installing, add there bin folder path in the Environment Variables of your machine.

Upgrade Java version for Web Application

I have a web Application and i need to upgrade java jre version from 6 to 7 .I am using Eclipse as IDE.I tried to update the Jre from eclipse .I have even updated the JAVA_HOME environment variable but i am getting following error
C:\Program Files\Java\jdk1.7.0_55\jre..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
Thanks
Download java hereand install it as a common application.
Then in Eclipse use Window->Prefrences->Java->Installed JREs
#Roman Bondar I guesss OP wanted to know more than just the setting.
Basically, JREs are meant to be downwards compatible, so that you are able to execute java classes compiled with version 6 with a runtime from java 7.
But as always, there may be special cases when things have to be changed, e.g. container or libraries. I remember a case back when I migrated to java 6 that it required a special version of JBoss.
Check out this Oracle blog as a starting point.

JNLP should use a specific Java version but error results

I'm facing a problem here. I want to use a special version to run our java webstart application but just for one jnlp. ("It was tested, ... blabla we can't use a new version... blabla" by random windbag)
So I tried to configure our JNLP like this:
<resources>
<j2se version="1.6.0_29" href="http://java.oracle.com/products/autodl/j2se"/>
...
</resources>
When I start this jnlp now I get following Error even if the right Java is installed:
Error: The application has requested a version of the JRE (version 1.6.0_29) that currently is not locally installed. Java Web Start is unable to automatically download and install the requested version. This JRE must be installed manually.
Update
In the JNLP File Syntax it's allowed to use a specific Java version like 1.6.0_29. I even tried it with 1.6.0_29-b11 - still the same error.
Exact product versions (implementation versions) may also be
specified. by including the href attribute. For example, 1.3.1_07,
1.4.2, or 1.5.0-beta2 by Sun Microsystems, Inc. For example,
<j2se version="1.4.2" href="http://java.sun.com/products/autodl/j2se"/>
or
<j2se version="1.4.2_04"
href="http://java.sun.com/products/autodl/j2se"/>
Edit
The given answer is not helping and not the right answer.
This is quite common. Make sure that each client machine has enabled 1.6.0_29 for JNLP/Webstart.
Installing 1.6.0_29 is not necessarily enough to tell webstart that it's available. See this post for more information
I had installed Java 1.6.0_21 and it was enabled at the Java Control Panel. However I got the same error message that it's stated in the question: "The application has requested a version of the JRE (version 1.6.0_29) that currently is not locally installed"
I got this message even if I tried with different lines in the JNLP, such as:
<j2se version="1.6.0_29"/>
or
<j2se version="1.6.0_29-b06"/>
I solved this by editing the JNLP file with the following line:
<j2se version="1.6"/>
So the documentation line "Exact product versions (implementation versions) may also be specified" seems to be false.
Do you use :
jnlp spec="1.0+"
If so you should try with :
jnlp spec="6.0+"
I found this link, maybe there is something wrong in the configuration of your browser/JRE, or are you under a proxy?
Troubleshoot:
Check the the version currently assigned to your project build path of your IDE
Make sure the version specified in j2se version="1.6.0_29" is installed on client machine.
Check your machine to see if you do not currently have any other versions currently installed which might cause dependency conflict.
Check your classpath setting to see the version currently set by default. Could this be the right version?
Also note that:
The j2se element specifies what Java 2 SE Runtime Environment (JRE)
versions an application is supported on, as well as standard
parameters to the Java Virtual Machine.
Therefore if you are looking to release the application to some specific versions, all the versions supported should be listed. Example:
<j2se version="1.3" initial-heap-size="64m"/>
<j2se version="1.4+"/>
In your case you've specifed the href attribute forcing Java Web Start not to consider an installed non-FCS (i.e., milestone) JRE as a match.
By convention a non-FCS (milestone) JRE if there is a dash (-) in the
version string. And so would not consider an installed 1.4.1-ea or
1.4.2-beta JRE as a match for the request.
Edited.
Auto-download of Software from java.sun.com
Try this url
j2se version="1.6.0_05+" href="http://java.sun.com/products/autodl/j2se"/>
if there are higher versions installed on the client machine the newest will used.
or
j2se version="1.6.0_05" href="http://java.sun.com/products/autodl/j2se"/>
then you will be prompt to install exactly 1.6.0_05.
when calling ?.jnlp versions 1.6.0_05 will be used.
be careful; above only works right when there's also i higher version installed then as example 1.6.0_29 runs 1.6.0_05 as a child.
In the Java Console you will see:
JavaPlug-in 1.6.0_31
Using JRE-Version 1.6.0_05 Java Hot Spot(TM) Client VM
If you really want to download a version not listed in the "The packages currently available for auto-download " then you can download the specified version 1.6.0_29 only if you have a greater version then 1.6.0_29 (maybe 1.6.0_31) as plugin enabled in the client browser. TEST install 1.6.0_31 and look if as Example: Firefox plugins 1.6.0_31 is there and enabled. Then the client will be able to automatic download and install 1.6.0_29 via *.jnlp.
Call your Application in a client browser. A warning appears : "Install a lower Version 1.6.0_29" and a "certificate warning" click yes. install 1.6.0_29 starts.
After Download the Browser restarts and the plugin 1.6.0_31 is gone!!! Therefore
the Browser redirects to the Oracle download-side there you have to install the 1.6.0_31 again. Download starts to a folder you specified . Run the file "jxpinstall.exe" that starts the update; prompt to question install again ; yes (all browser must be closed) Install starts; Look at extras, plugins and there the 1.6.0_31 plugin is back again. Now you can use your *.jnlp application with 1.6.0_29. Really much work :-)
NOTE: You will not be able to install the browser plugin again with a file like "jdk-6u31-windows-i586.exe" You must follow the steps above. You will get a file "jxpinstall.exe" that is the right one.
The java.sun.com auto-download feature simplifies Java Web Start deployments because it makes commonly used software readily available for use with Java Web Start. Typically, only an extra line has to be added to a JNLP file to take advantage of this feature. ...
The packages currently available for auto-download are:
Java 2 Runtime Environment 1.3.0_02 for Windows/i586, Linux/i586, and Solaris/SPARC
.....
Java 2 Runtime Environment 1.4.2_16 for Windows/i586, Linux/i586, and Solaris/SPARC
Java Runtime Environment 1.5.0_02 for Windows/i586, Linux/i586, and Solaris/SPARC
.....
Java Runtime Environment 1.5.0_14 for Windows/i586, Linux/i586, and Solaris/SPARC
Java Runtime Environment 1.6.0 for Windows/i586, Linux/i586, and Solaris/SPARC
Java Runtime Environment 1.6.0_04 for Windows/i586, Linux/i586, and Solaris/SPARC
Java Runtime Environment 1.6.0_05 for Windows/i586, Linux/i586, and Solaris/SPARC
available packages look here
Its the damn java version, use of the lower versions fixes the issue. I used Java 1.8.0_05-b13 Java HotSpot(TM) 64-Bit Server VM and it went through successfully.

Using Java 1.4 for applet when 1.6 is installed

My Java applet only supports 1.4 java run time(1). I am having one machine on which both Java 1.4 and 1.6 environment is installed. Is there some setting available by which I can make sure my applet will always use Java 1.4 run time when it runs?
We are using key event class private data array bData with the help of Java reflection. The data which is there in this array JDK 1.4 and 1.6 is different in both the version.
A Java application compiled with JDK 1.4 will run on JDK 1.6.
You can compile a Java application with JDK 1.6, but compatible with JDK 1.4 by configuring the 'source level'.
Although you can choose your default JDK to be safe, but it depends on your operating system. If you are on Linux, you can choose between available Java versions using pdate-alternatives --config java command (which will modify some symlinks in the hindsight).
On Windows 7:
Control Panel -> Programs -> Java
Select 'Java' tab, and View the Java Runtime Environment settings.
Ensure that your Java 1.4 entry is selected.
There's a way to force a specific installed version to run, but if one Java plugin replaces the other there might be an issue with this. See linked question for further details.
Force Internet Explorer to use a specific Java Runtime Environment install?
Are there any issues with running the 1.4 code on 1.6? If not, you should be fine. Just avoid using anything in the classpath that changed significantly between these versions. Otherwise, look [here][1]. The codebase download thing is interesting, since it lets you download a different classpath. So, regardless of the JRE version, you could force the download of a 1.4 JRE classpath, which should ensure full compatability.
Edit: found an updated guide to using previous classpaths with newer Java versions in applets, which actually seems to work:
http://download.oracle.com/javase/tutorial/deployment/applet/deployingApplet.html
Edit 2: I actually have it working, but it appears to need to download JRE 1.4 and install it, but then it will run the applet with it automatically. However, this might be suitable for your needs.
http://www.2shared.com/file/bl3Rua2e/applet.html -- extract the archive, and then run index.html inside this. All source code is included.

Categories

Resources