1

i'm trying to connect java with constraint logic, i'm using netbeans for java and eclipse 6.1 for constraint logic, but when i'm trying to run the code there is an exception appears java.lang.IllegalArgumentException: Missing eclipse.directory property

i've used a tutorial that explain how to connect them, which says that After compilation, to run the program, start the Java interpreter as you normally would but before the name of the class, supply the command line option -Declipse.directory=<eclipse_directory>

and i don't know where to place it in netbeans

here is the code

import com.parctechnologies.eclipse.*;
import java.io.*;
public class eclipseConnection {    
    public static void main(String[] args) throws Exception
  {
      try{

    EclipseEngineOptions eclipseEngineOptions = new EclipseEngineOptions();
    EclipseEngine eclipse;
    eclipseEngineOptions.setUseQueues(false);
    eclipse = EmbeddedEclipse.getInstance(eclipseEngineOptions);
    eclipse.rpc("write(output, 'hello world'), flush(output)");
    ((EmbeddedEclipse) eclipse).destroy();
  }catch(Exception e){
      System.out.println(e);
  }
  }
}
t0r0X
  • 4,212
  • 1
  • 38
  • 34
  • You should name your class `EclipseConnection`, in Java it's usual to start type names (i.e. classes, interfaces, enumerations) with capital case. – t0r0X Feb 21 '16 at 22:32

2 Answers2

1

You can add the property definition in the 'Run' menu: Run > Set Project Configuration > Customize.... Make sure you enter the property definition -Declipse.directory=<eclipse_directory> in the VM Options section.

t0r0X
  • 4,212
  • 1
  • 38
  • 34
  • Thanks a lot, i've set the directory, but there is another exception appears "Exception in thread "main" java.lang.UnsatisfiedLinkError: The shared library C:\Program\ECLiPSe\lib\i386_nt\ec_java_load.dll could not be found." and the dll file already exists – Rana Mohamed Feb 22 '16 at 15:53
  • "the dll file already exists" : were does the file exist? Ánd which is the `` you configured? – t0r0X Feb 22 '16 at 20:00
  • the eclipse directory is C:\ Program Files\ECLiPSe and the dll file exist at the path C:\Program Files\ECLiPSe\lib\i386_nt\ec_java_load.dll – Rana Mohamed Feb 22 '16 at 21:00
  • Ok, you probably need to escape the space character. Try putting the directory name in double quotes, e.g. `-Declipse.directory="C:\Program Files\ECLIPSe"` or `"-Declipse.directory=C:\Program Files\ECLIPSe"`. In worst case you will have to use the 8.3 name of the directory: `-Declipse.directory=C:\Progra~1\ECLIPSe`. PS Note for the future: never ever install your tools under or in a directory with spaces in it's name. You'll save yourself a lot of trouble, as you can see now. – t0r0X Feb 22 '16 at 22:14
  • @RanaMohamed I'm glad it worked. If you think my answer helped you and might help others, please mark it as the accepted answer. – t0r0X Feb 26 '16 at 22:32
0

Let's use the command line and the example source file Quicktest.java.

Copy the example:

copy "C:\Program Files\ECLiPSe 6.1\doc\examples\JavaInterface\Quicktest.java" .

Compile it:

javac -classpath "C:\Program Files\ECLiPSe 6.1\lib\eclipse.jar" QuickTest.java

Run it:

java -classpath ".;C:\Program Files\ECLiPSe 6.1\lib\eclipse.jar" -Declipse.directory="C:\Program Files\ECLiPSe 6.1" QuickTest
hello world
jschimpf
  • 4,904
  • 11
  • 24