Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Compiling project with lower Java version
icon5.gif  Compiling project with lower Java version [message #534014] Mon, 17 May 2010 13:49 Go to next message
Eclipse UserFriend
Howdy All!

I'm failing to find the answer so I'll turn to here for help and direction. I'm developing a Java application with Eclipse 3.5 under Windows XP which has the Java 1.6 JRE installed on it. The professor I work for would, at times, like to run the application on his MacBook which has Java 1.5.0_16 installed. (He is doing an update now, which should take it to Java 1.5.0_22.) I am having difficulty getting Eclipse to create a runnable JAR file that he is able to run on his Mac.

I've tried a number of things I'll specify below, but every time he runs the JAR files I send him in the Console he gets a message saying " Bad version number in .class file".

As for what I've attempted so far:
* I've installed older versions of the Sun Java JDK on my computer (including 1.5.0_22, 1.5.0_16, and 1.5.0_13). In Eclipse, under Windows -> Preferences ->Java -> Installed JREs I've added these JDKs to the list.
* In Windows -> Preferences -> Java -> Compiler I've set the "Compiler compliance level" to 1.5. (I realize this should have no effect on the result of the JAR files, but I've included it for completeness).
* For my project, I went into Build Path -> Configure Build Path -> Java Build Path -> Libraries. I selected the 1.6 JRE System Library, clicked "Edit", then selected the "Alternate JRE" and specified the 1.5 JDKs (listed above, I've tried this with both 0_16 and 0_13).
* I then create a Runnable Jar file through the export feature like usual. They run fine the Windows and Linux machines I've tried it on, but still get the bad version number error on my professor's mac.

Is there something I'm doing wrong in creating a JAR file for him to run on his Mac? Is there a web page with the answer I'm not finding?

Thanks for your help.
--Christian
Re: Compiling project with lower Java version [message #534078 is a reply to message #534014] Mon, 17 May 2010 17:41 Go to previous messageGo to next message
Eclipse UserFriend
"Christian" <cm1481@txstate.edu> wrote in message
news:hsrvjc$j5a$1@build.eclipse.org...
> Howdy All!
>
> I'm failing to find the answer so I'll turn to here for help and
> direction. I'm developing a Java application with Eclipse 3.5 under
> Windows XP which has the Java 1.6 JRE installed on it. The professor I
> work for would, at times, like to run the application on his MacBook which
> has Java 1.5.0_16 installed. (He is doing an update now, which should
> take it to Java 1.5.0_22.) I am having difficulty getting Eclipse to
> create a runnable JAR file that he is able to run on his Mac.
>
> I've tried a number of things I'll specify below, but every time he runs
> the JAR files I send him in the Console he gets a message saying " Bad
> version number in .class file".
>
> As for what I've attempted so far:
> * I've installed older versions of the Sun Java JDK on my computer
> (including 1.5.0_22, 1.5.0_16, and 1.5.0_13). In Eclipse, under
> Windows -> Preferences ->Java -> Installed JREs I've added these JDKs to
> the list.

This just makes the jdk available. Unless you select it, it will never be
used. It is an important first step in the process but not the only step.


> * In Windows -> Preferences -> Java -> Compiler I've set the "Compiler
> compliance level" to 1.5. (I realize this should have no effect on the
> result of the JAR files, but I've included it for completeness).

This is also required. You need to build 1.5 compliant class files in order
to run them on a 1.5 jre.

> * For my project, I went into Build Path -> Configure Build Path -> Java
> Build Path -> Libraries. I selected the 1.6 JRE System Library, clicked
> "Edit", then selected the "Alternate JRE" and specified the 1.5 JDKs
> (listed above, I've tried this with both 0_16 and 0_13).

This is also correct. This will cause the 1.5 runtime libraries to be used.
Since the 1.5 libraries may have different methods than the 1.6 libraries,
this could cause some compiler errors in your projects. Insure that there
are no compiler errors.


> * I then create a Runnable Jar file through the export feature like usual.
> They run fine the Windows and Linux machines I've tried it on, but still
> get the bad version number error on my professor's mac.

Insure that you have performed a full build of all class files in the
project. The best way to do this is to perform a Project->Clean. If you
perform this step after all of the above steps, you should get a 1.5
compliant jar.

Make sure that the jar file is actually getting created. Perhaps you can
delete/rename the existing jar before exporting to make sure it is created.


You should be able to test this out on your system by using the 1.5 version
of java to run your jar file. /{path to 1.5jdk/java -jar my.jar.

>
> Is there something I'm doing wrong in creating a JAR file for him to run
> on his Mac? Is there a web page with the answer I'm not finding?
> Thanks for your help.
> --Christian
Re: Compiling project with lower Java version [message #534599 is a reply to message #534014] Wed, 19 May 2010 11:47 Go to previous messageGo to next message
Eclipse UserFriend
Make sure you set 1.5 and its default settings in the compiler preference page of your project.

Let me know if you still have issues.

Olivier
Re: Compiling project with lower Java version [message #534693 is a reply to message #534599] Wed, 19 May 2010 19:15 Go to previous message
Eclipse UserFriend
Thank you David and Oliver. I did not see the additional compiler setting on the project level, so I changed that as well as the other compiler settings. I also went to Project -> Clean, another option I hadn't tried. When I run the application from the command line using the "older" Java JRE, it runs just fine. I'll get my professor to try it on his Mac and hopefully all will be well.

Thanks again!
Previous Topic:Plug-in Missing: org.eclipse.jdt.core
Next Topic:[Formatter] Function calls don't honor indentation settings?
Goto Forum:
  


Current Time: Sat Mar 22 09:22:13 EDT 2025

Powered by FUDForum. Page generated in 0.04262 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top