Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Openmodelica & Netbeans on Mac OSX Mavericks

Openmodelica & Netbeans on Mac OSX Mavericks

Hello,

I'm trying to use the OpenModelica Java interface on my Macbook Air running Mac OS X 10.9 Mavericks.
I use OpenModelica release 17983 (1.9.1+dev) and I'm programming using Netbeans IDE with JDK 1.7 update 45.

I tried the following code to check if everything works:

Code:


package javaapplication1;

import org.openmodelica.corba.ConnectException;
import org.openmodelica.corba.OMCProxy;

public class JavaApplication1 {

    /**
     * @param args the command line arguments
     * @throws org.openmodelica.corba.ConnectException
     */
    public static void main(String[] args) throws ConnectException {
        // TODO code application logic here
        OMCProxy omc = new OMCProxy("bdezhohidhoz");
        omc.sendExpression("cd()");
        omc.stopServer();
    }   
}

When I run the application, I get the following error :

Code:


run:
Warning: 'Mac OS X' not officialy supported OS
Exception in thread "main" org.openmodelica.corba.ConnectException: Unable to start the Open Modelica Compiler. Waited for 5 seconds, but it didn't respond.
    at org.openmodelica.corba.OMCProxy.startServer(OMCProxy.java:336)
    at org.openmodelica.corba.OMCProxy.init(OMCProxy.java:421)
    at org.openmodelica.corba.OMCProxy.sendExpression(OMCProxy.java:497)
    at javaapplication1.JavaApplication1.main(JavaApplication1.java:25)
Java Result: 1
BUILD SUCCESSFUL (total time: 5 seconds)

OPENMODELICAHOME variable is set to "/opt/openmodelica/bin".

Could you pls help me fixing this error ?

Thanks in advance, best,

Re: Openmodelica & Netbeans on Mac OSX Mavericks

It should be /opt/openmodelica if anything (I'm unsure if the Java stuff includes workarounds to try and find omc anyway)

Re: Openmodelica & Netbeans on Mac OSX Mavericks

Hello,
Thanks for your reply.
The Java library includes workarounds to try and find omc executable.

It finds :
omcBinary = /opt/openmodelica/bin/omc
omcWorkingDirectory = /opt/openmodelica

I checked the library and it tries to create a file named "/tmp/openmodelica." + username + ".objid." + corbaSessionName
But when I check in the tmp folder, there is no openmodelica.xxx file.
It seems omc fails creating tmp file :

Code:

int ticks = 0;

    while(!f.exists())
    {
      try
      {
        Thread.sleep(100);
      }
      catch(InterruptedException e)
      {
        /* ignore */
      }
      ticks++;

      /* If we've waited for around 5 seconds, abort the wait for OMC */
      if(ticks > 50)
      {
        logOMCStatus("No OMC object reference file created after " +
        "approximately 5 seconds.");
        logOMCStatus("It seems OMC does not want to come up, giving " +
        "up.");
        throw new ConnectException
        ("Unable to start the Open Modelica Compiler. Waited for 5"
            +" seconds, but it didn't respond.");
      }
    }

Is it an issue regarding permissions for the tmp folder which currently are:

lrwxr-xr-x@  1 root  wheel       11 26 oct 21:28 tmp -> private/tmp

And private/tmp :
drwxrwxrwt  11 root  wheel   374  2 déc 09:54 tmp

Thanks in advance.

Best,

Re: Openmodelica & Netbeans on Mac OSX Mavericks

Then you need to set the TMPDIR env.var because the tmp directory is not /tmp on OSX.

Re: Openmodelica & Netbeans on Mac OSX Mavericks

I added an osType in OMCProxy.java to consider TMPDIR environment variable for OSX.
There also was an issue regarding my firewall which blocked Corba connection between Java and omc.

Do you know if it is possible to use Corba interface without completely switching off my firewall ?

Re: Openmodelica & Netbeans on Mac OSX Mavericks

Allow connections from localhost to localhost?

Re: Openmodelica & Netbeans on Mac OSX Mavericks

It seems to work now.
Thanks again for your help.

There are 0 guests and 0 other users also viewing this topic
You are here: