-3

I have been working on an application which was originally built with JDK 1.5.0. While playing around with the application I have somehow regenerated the classes to version 1.6.0.

Due to classes being updated the java compiler version 1.5 cannot run these classes anymore. Is there any way i can rebuilt the classes to use JDK 1.5.0. Moreover, when i try to use jdk 1.5 to compile my code, i get a JVM error saying "Could not find the main Class. Program will exit"

Please help.

  • What difference would that make. I ddnt make any code changes. Just changed some configuration in eclipse. Next time please don't comment and give negative feedback to people if you find yourself confused with the information provided. – Nitin Jaitely Aug 24 '15 at 15:37
  • No I gave negative feedback. See two votes for me it means they are also asking for code. You are new here first try to learn how to post a good question. – RajSharma Aug 24 '15 at 16:24
  • May be they are your friends. Lol. Endless possibilities. – Nitin Jaitely Aug 24 '15 at 17:41
  • You got three down votes. May be they are your foes. Lol..... – RajSharma Aug 25 '15 at 00:01

1 Answers1

0

Is there any way I can rebuild the classes to use JDK 1.5.0.

You can use the -source and -target options to instruct javac to target an earlier JVM.

If you are using Eclipse's compiler, instead of the JDK's javac, then you set the compiler settings in the project properties.

http://help.eclipse.org/mars/topic/org.eclipse.jdt.doc.user/gettingStarted/qs-with-j2se50.htm?cp=1_1_2

http://help.eclipse.org/mars/topic/org.eclipse.jdt.doc.user/reference/preferences/java/ref-preferences-compiler.htm?cp=1_4_2_0_3

"Could not find the main Class. Program will exit"

This means the CLASSPATH (and/or bootclasspath) does not contain the class specified as the 'main' class to run.

How are you running javac? Are you maybe trying to compile using a JRE 5? That won't work as the JRE does not contain the compiler; you need a JDK.


Note that both 1.5 and 1.6 have been End-of-Life for a few years now (since 2009 and 2013 respectively). I recommend using a currently-supported JVM.

dsh
  • 11,380
  • 3
  • 27
  • 48
  • I am building it using the ant scripts. In my class path variables i have defined the variables which are pointing to rt.jar and src.zip of version 1.5.0 – Nitin Jaitely Aug 24 '15 at 15:47
  • You do not need src.zip on the classpath; it won't help. You shouldn't need to specify rt.jar either. That may be why you are getting confusing errors. Just run ant with the correct JDK (ie set JAVA_HOME). – dsh Aug 24 '15 at 15:52