5

I'm working on a Java application, where I need to use a jar called myBeans.jar.

This myBeans.jar contains lots of class files, that are compiled with jdk 1.7. I don't have the source code for those class files.

And my whole application is using jdk 1.6. I can't change it's compiler to jdk 1.7. So I want my jar to be compatible with my app. And that's why I want the classes of the jar to be compiled with jdk 1.6.

Now my question is: Is there any way to compile the class files (& not java files) using jdk 1.6?

Any alternate suggestions are also welcome.

Someone recommended me to get the source code from class files using decompiler & then compile the source code with jdk 1.6. But I would prefer this solution at the last as there are lots of class files.

10
  • 1
    Have you checked if there is an older version of MyBeans.jar that was compiled with java 6? If it is a downloaded library they might have an archive. Commented Jul 4, 2013 at 9:40
  • 3
    +1,but not possible I guess stackoverflow.com/questions/6699347/… Commented Jul 4, 2013 at 9:40
  • @DanielLerps Yes I have checked but I'm not able to find the older jar. Commented Jul 4, 2013 at 9:42
  • 1
    .class files are already compiled. You compile .java files, not .class files. Commented Jul 4, 2013 at 10:17
  • 1
    The original title was poor and described a possible solution, not the problem in hand. Hopefully my edit makes it easier to see what this question is about. Commented Jul 4, 2013 at 14:18

1 Answer 1

3

This will probably not work. Java 7 has introduced language features not present in earlier versions, so if any of these have been used in the library you may not be able to recompile using JDK 6.

Also, new methods and classes are introduced with each Java revision, so if any @since 1.7 items are used in the library, they will not be present in your Java 6 environment and the build will fail.

Sign up to request clarification or add additional context in comments.

3 Comments

Any online tool or plugin or something..?
@RAS I don't know of an approach to take other than the manual decompile/recompile suggested by your acquaintance.
I want my jar to be compatible with my app. App is compiled using jdk 1.7 & jar is compiled using jdk 1.6. I can't change app compilation to be jdk 1.7.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.