问题
So I am trying to use omp4j with the eclipse IDE. The problem is, that omp4j needs to replace the javac command to work (see http://www.omp4j.org/download). And I don't know how I can accomplish that in eclipse other than renaming the omp4j.jar
to javac.jar
and replacing my JDKs javac.jar
and that seems like a wrong solution.
回答1:
omp4j
is a preprocessor. If omp4j
is called without --no-compile
, the preprocessed Java source code will be automatically compiled via javac
, so omp4j
can be used as a replacement for javac.
Eclipse has its own incremental Java compiler which can not be replaced. This means, in Eclipse omp4j
has to be used with the argument --no-compile
as preprocessor only. The processor can be executed
- in an Ant, Maven, Gradle, etc. build script or
- via an Ant build script as project builder on save.
To have the full Java support for the sources before preprocessing, the OMP4J_THREAD_NUM
and OMP4J_NUM_THREADS
constants can be faked via a static import statement with the *
wildcard and a JAR that exists in two different versions, one with these face constants for the sources to edit and one with other constants for the generated sources which are not intended to be edited.
Probably it will be best to start with a Java project for each, before and after preprocessing.
来源:https://stackoverflow.com/questions/52833784/set-custom-compiler-in-eclipse-omp4j