Skip to main content
1-Visitor
October 16, 2015
Solved

Use MKS Java Api from MATLAB

  • October 16, 2015
  • 2 replies
  • 2563 views

Hello PTC community,

i'm trying to call the MKS Java Api from MATLAB (Release 2010b 32 bit).

This is because I want to avoid having an external java-class since our main code is all in MATLAB and running Java classes in Matlab was never an issue before.

It all looks good at the beginning, however, when running the cmdRunner-Class, i encounter a Java exception.

Below is an excerpt of the code (MATLAB M-File format) that i'm trying to run. The full m-file with more information is also attached.

When I run the same code from an external Java class in the JRE, everything is working fine. (Thus it shouldn't be the connection to the server)

Is there somebody who could help me with this? Any help would be greatly appreciated.

Thanks,

Stefan

javaaddpath('C:\Matlab\WORK\mksapi.jar');

javaclasspath('-dynamic');

import java.util.List;

import com.mks.api.*

import com.mks.api.response.*;

import com.mks.connect.*;

ipf = IntegrationPointFactory.getInstance();

APIVersion=util.APIVersion(4,11); % Was also tested with 4,15

IntegrationPoint = ipf.createIntegrationPoint('SERVERNAME',7001,true,APIVersion); 

Session = IntegrationPoint.createSession('USERNAME','PASSWORD');

CmdRunner = Session.createCmdRunner();

% CmdRunner-Test:

CmdRunner.toString()

% Answer:

% com.mks.connect.HttpCmdRunnerImpl@2bce4f

cmd = Command(Command.SI,'about');

resp = CmdRunner.execute(cmd);

% Answer:

% ??? Java exception occurred:

%

% (no more information...)

    Best answer by tdalon

    Hi

    You can have a look to the MATLAB code provided in the PTC "MathWorks Integration".

    Download from https://support.ptc.com/

    under Features "Mathworks Integration".

    HTH.

    Thierry

    2 replies

    16-Pearl
    October 28, 2015

    Hello Stefan,

    I suspect the intersection of Integrity & MatLab users is quite small here.  Please contact PTC Integrity Lifecycle Management Support‌ to open a case to investigate with you.

    Regards,
    Kael

    tdalon1-VisitorAnswer
    1-Visitor
    October 29, 2015

    Hi

    You can have a look to the MATLAB code provided in the PTC "MathWorks Integration".

    Download from https://support.ptc.com/

    under Features "Mathworks Integration".

    HTH.

    Thierry