简体   繁体   中英

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.

 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM