In Eclipse Java, while developing a Java Project, I can easily use these methods to compile external Java files:
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
compiler.run(null, null, null, javaNamesArray);
However, the exact same thing in Eclipse DSL, in an Xtext Project, isn't working because the JavaCompiler object doesn't find the JARs (which are in the classpath) nor the class binaries from my own project. In order to be able to compile, I have to export the classes I need and tell the compiler where they are as well as the JARs.
Why is the compiler behavior so different in an Xtext project? What am I missing?
ps: then, when loading the classes, the problem repeats itself
Edit:
Example
I have this interface in my code:
public static interface CustomSWRLInterface {...}
Then I create an external Java file ("swrl1.java"), which contains the class:
public class swrl1 implements CustomSWRLInterface {...}
I run the Xtext Project as an Eclipse Application which loads the environment where I can code in my DSL. I have then a Validator which tries to compile the external swrl1.java to swrl1.class. However, it gives a lot of errors like this:
C:\Users\Manuel\Documents\EclipseDSLNeon\runtime-DSL1\Test\swrl\swrl1.java:4:
error: package org.mindswap.pellet does not exist import org.mindswap.pellet.ABox;
It doesn't find the JARs associated with these imports nor the internal class where I defined the interface. This problem only happens in the Xtext Project, which leads me to think that, when launching the Eclipse instance, something happens to the classpath or the visibility of loaded classes (but I have no idea how to work around it).