ali honarmand
ali honarmand

Reputation: 57

version mismatch in java

I'm working on a university project which is based in cloudsim3.0 project. I'm using jdk 7 while the cloudsim uses jdk 1.3. So I have to change everything: generics, for-each loops , etcetera. Some of the errors I received from NetBeans are:

How can I change the jdk version from 1.3 to 7? Thanks

Upvotes: 0

Views: 434

Answers (2)

Stephen C
Stephen C

Reputation: 718956

Your question is a bit confused, but it makes most sense if you are asking how to compile Java 7 source code for JDK 1.3.

And the answer is that you can't. Those constructs (generics, for-each loops, string switches) all require a more modern target platform.

In theory, you've got two possible solutions:

  • Remove all the Java 5,6,7-isms from your code and compile with -source 1.3 -target 1.3. (Or download and install an old Java 1.3 JDK.)

  • Run the CloudSim3.0 code using a Java 7 JVM. It should work, unless it depends on old bugs that have been fixed.

Upvotes: 1

Generally you want to be very careful with developing in a higher Java version than you deploy to. The java compiler in the JDK which is what Netbeans uses do not support compiling Java 7 source to 1.3 bytecode, so you need to use another compiler which do.

I spent some time a while back investigating this for targetting Java 1.4, and you can use the Eclipse compiler either directly inside Eclipse or as ecj (which is a javac drop in replacement from the command line) which can be used inside ant, or you can use Retroweaver which actively converts byte code to an earlier version.

You might consider just biting the bullet and use Java 1.3 for your project, as it removes all these magic bullets from what you need to investigate if your code for any reason does not work.

Upvotes: 1

Related Questions