Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two separate JREs for junit and source in eclipse project

Below is my project structure.

-project
   -sources
       -my.package
             -MyClass.java
   -test
       -my.package
             -MyClassTest.java

I want to use JDK version less than 1.5 for my source.

Where as my junit test classes needs latest JDK.

Is there any possibility to use two different JDKs for same project.

Current solution: I can configure latest JDK for the project and can compile using different targets one for source and one for test. javac -target.

Is that correct way to do? or Please suggest any correct solution.

Thanks in advance.

like image 362
Konda Reddy R Avatar asked Jun 09 '26 22:06

Konda Reddy R


1 Answers

In an Ant build, you can freely specify different JDK and compiler settings for different source folders.

But for Eclipse compilation, I think you will be restricted to using one JDK and compiler settings per-project. I don't think you can specify separate compiler per folder in an Eclipse project.

Options:

  • Treat these folders as separate Eclipse projects. Or,

  • Implement Ant build for both folders, but Eclipse build only for one of them. For example, your junit classes would be built by Ant only.

like image 117
sudocode Avatar answered Jun 11 '26 13:06

sudocode



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!