Java JRE versions incompatibilty - java

I have a question regarding the compatibility between different java versions.
On my computer, I have java version "1.7.0_02".
But when I uploaded the .class and embedded it in a webpage it does not work
I get the error:
"Unsupported major.minor version 51.0"
the heading at the top of the console says:
"Java Plug-in 1.6.0_31
Using JRE version 1.6.0_31-b05 Java HotSpot(TM) Client VM"
I would like to ask what is causing the problem. Is it really my java version?
I mean, I visited the site with the computer I compiled the applet in.

You can't use classes compiled to Java 1.7-compatibility class files with an earlier virtual machine, and that "Java Plug-in" error you're seeing says that's exactly what happen.
Two options:
if you're not using Java 1.7 only features, you can compile your code to be compatible with 1.6 JVM's using the option -target 1.6 (see docs here)
Upgrade the Java plug-in your browser is using to 1.7, if possible (I don't think you can do this on OS X, for example). You didn't note what OS and browser you're using so I'm not sure what the upgrade path would be, if any.

Thanks for the answers, I figured out what was wrong.
I started off with both 1.7 and 1.6 on my machine, and it was really confusing me.
The problem was, 1.7 was 64 bit, and 1.6 was 32 bit.
My browser was chrome 32 bit.
I just installed 1.7 32 bit and it was fine

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.

Can I use a specific bit version (32 or 64) of java for compilation through the terminal?

Here are some details about my system:
Windows 7 (64-Bit)
JDK 1.8.0_05 (64-Bit)
JDK 1.7.0_51 (32-Bit)
Eclipse - Luna 4.4.0 (64-Bit)
Although my eclipse uses the 64-bit version of Java, I want to compile a Java program using the 32-bit version through the terminal.
Any suggestions how I can do that?
If you find that the Windows or Linux or Mac or 32-bit or 64-bit compiler produces a different output, this is most likely a bug (unless the compiler runs out of memory) Note: Eclipse has it's own compilers and it might generate different .class files. Usually this doesn't matter however when it does it can lead to subtle inconsistencies. I would make sure you always use the Oracle or IBM compiler if you can to avoid these issues.
However, you can specify the bit-ness in the same way you specify the version by setting the PATH or using the whole path when you run it. If you use an IDE, this is what it does for you, and many, many other things.

Flex mxmlc error loading JVM windows 7 64 bit

I'am executing this command in my windows 7 console:
mxmlc
then I get:
Error loading: C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll
How to fix this?
the jvm.dll exists in that directory, but why the error occurs?, I've tried to reinstall java, but it didn't helped
The flash compiler, mxmlc, does not run under a 64 bit jvm. According to the 4.6 SDK docs:
Note: You must use a 32-bit version of the JDK, version 1.5 or later. The command line compilers do not work with a 64-bit JDK.
Unfortunately, You will need to install a 32 bit jvm.

Issues running Java applets

Recently I'm studying Java. I had no real troubles while building normal java files to .class and execute them, but, when I started a bit with applets I haven't been able to run anything.
Before I had started Java, as developer I had already a lot of development tools (Eclipse, Visual Studio, CodeBlocks and others). So, basically, I already had JDK but downloaded it again to get updated to 1.8.
Now, I have also JRE 8 and there are no troubles in using javac.exe and java.exe to build and execute, but, after building the .class file of applet, when I load the html page, I got an error which strongly recommends me to upgrade JRE.
Just to translate it:
Current version of Java is obsolete.
Upgrade (recommended choice)
Block
Later
If I do the update, it gets me to this page http://java.com/it/download/index.jsp), but, it's the download link of JRE 1.7. As much as I know, JDK 1.8 is not beta (it's accessible a 1.9 preview) so why shall I use 1.7? Indeed, after downloading and installing, when I try to run the applet, the message above is shown again.
Is actually possible to install JRE 1.8 on Google Chrome?
I resolved it. It wasn't easy since it wasn't a real trouble of java.
I had effectively Java 7 version 55 and Java 8 (but also 7-45 and 6). Java 8 was 64-bit while Java 7 was 32.
Google Chrome (32-bit browser) used so the last version it could use. According to Oracle, it's recommended to remove older versions of java (because of security) so I removed everything but the 8, and then switched to 64-bit browser (Chromium). I left older JDK installed for compatibility development reasons.

Does anyone know if NetBeans 6.x can be used with Java SE 6 on Leopard?

Java SE 6 (64 bit only) is now on OS X and that is a good thing. As I understand it since Eclipse is still Carbon and thus 32 bit, it cannot be used for 1.6 on Leopard, only 1.5.
Does anyone know if NetBeans 6.x can be used with Java SE 6 on Leopard utilizing its JVM?
Yes, you should be able to.
A number of blogs have reported running Netbeans on 1.6 as well as the the problems they had with earlier versions of NB. The NB issue tracker also has a number of bugs that have been fixed that affected 1.6 on Mac OS.
If you have trouble getting it to run, you might also try the Netbeans forum.
Eclipse works with java 1.6, kinda. Ecplipse runs using the 1.5 vm, but it can compile code for 1.6 using the 1.6 java compiler. I have used netbeans for 1.6 development and it seems alright.
I haven't tried it yet, but can't think of any reason why not.

Categories

Resources