Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (4k points)

I am getting this error when I include an opensource library that I had to compile from source. Now, all the suggestions on the web indicate that the code was compiled in one version and executed in another version (new on old). However, I only have one version of JRE on my system. If I run the commands:

$ javac -version

javac 1.5.0_18

$ java -version

java version "1.5.0_18"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_18-b02)

Java HotSpot(TM) Server VM (build 1.5.0_18-b02, mixed mode)

and check in Eclipse for the properties of the java library, I get 1.5.0_18

Therefore, I have to conclude something else, internal to a class itself, is throwing the exception?? Is that even possible?

1 Answer

0 votes
by (46k points)

I've learned that error messages like this are usually right. When it couldn't POSSIBLY (in your mind) be what the error being reported says, you go hunting for a problem in another area...only to find out hours later that the original error message was indeed right.

Since you're using Eclipse, I think Thilo has it right The most likely reason you are getting this message is because one of your projects is compiling 1.6 classes. It doesn't matter if you only have a 1.5 JRE on the system, because Eclipse has its own compiler (not javac), and only needs a 1.5 JRE to compile 1.6 classes. It may be weird, and a setting needs to be unchecked to allow this, but I just managed to do it.

For the project in question, check the Project Properties (usually Alt+Enter), Java Compiler section. Here's an image of a project configured to compile 1.6, but with only a 1.5 JRE.

enter image description here

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...