I am trying to call matlab executable file from java application
i am try 2 option:
Process p=new ProcessBuilder("C:\\Users\\Dexter\\Documents\\MATLAB\\Project.exe").start();
Process p= Runtime.getRuntime().exec("C:\\Users\\Dexter\\Documents\\MATLAB\\Project.exe");
... these 2 options are work properly for another application like chrome, eclipse, et cetera
pls suggest the solution
I suppose that you are trying to run an executable exported from Matlab, within Java. I am not sure that this is going to work...
What you can do is to use the matlabcontrol library in order to open a session with Matlab and then you will be able to run Matlab commands directly, from Java, or run a Matlab script from Java, by giving some inputs and taking back the result from Matlab. I have created a server which does all the aforementioned, in Java, and using matlabcontrol library to connect with Matlab. You can find it here:
Connect Java with Matlab
Let me know if you need any further clarification.
Related
I want to know if there is some way to execute a jar console application by Delphi and give commands for it like a cmd.
Actually I have a java application that I don't have the source anymore and it's limited to only two commands by console, so I want to create a delphi application and it will have buttons instead console commands.
There is a way to do this?
I would like to know how to call and execute a matlab function with parameters using java and capture the output in java.
I see different options.
Create a JAR from your code, using the Builder JA.
Use matlabcontrol, which is a 3rd party automation server:
Use the MatlabControl.java, which allows to run matlab code from java running within the matlab JRE. enter link description here
While the Builder JA is expensive and the options 2 and 3 might get you in truble with future matlab versions, using the matlab CLI is another possibility which probably does not cause any maintenance. For parameters and return, I would use a file. The main disadvantage is a new matlab session starting for each call, which needs some time.
Please can you assist me on how to connect JAVA to IBM PCOMM and interact with its screen. Right now, I am just running IBM PCOMM using AutoHotKey (Run and SendInput), no API at all, just an automated keyboard input care of AHK script.
I am also thinking of writing AHK script to connect to IBM PCOMM and run it in my JAVA program as exe, but unfortunately, I don't know either how to write that script.
I am using Eclipse JUNO.
I'm also doing the same things like your. I'm using jacob - a com-java bridge component for java. I've just started my project for one week and the result I've got is quite fessible. Until know, I can wrap all the PCOMM com object by java and work with it properly. You can study jacob at this link: http://sourceforge.net/projects/jacob-project/ and danadler.com/jacob/ .
I need to start RMI server object java code from another java executable. When I try to run the main java program which calls the RMI java program using exec() function, I get ClassDefNotFound error. I am using eclipse. However, if i run the RMI program directly from console it works.
Can someone please help me to solve the issue.
Thank you
I need to start RMI server object java code from another java
executable.
Why? Why write two programs when one will do? Just export the remote object(s) from the 'other' Java program.
I have a Java program that is mostly GUI and it shows data that is written to an xml file from a c++ command line tool. Now I want to add a button to the java program to refresh the data. This means that my program has to call the c++ functionality.
Is the best way to just call the program from java through a system call?
The c++ program will be compiled for mac os and windows and should always be in the same directory as the java program.
I would like to generate an executable can the c program be stored inside the jar and called from my program?
If you have access to the code and want an 'interactive' experience with the external program (e.g., make call, get results, make additional calls), investigate JNI, which allows you to call C or C++ code from a Java application by including & linking JNI juice to your C or C++ app with .
See:
http://en.wikipedia.org/wiki/Java_Native_Interface
http://www.acm.org/crossroads/xrds4-2/jni.html
If you really just need a "launch app and get results" sort of solution, check out Runtime.exec(), which lets you launch an external program & capture its output.
See:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=1
http://www.rgagnon.com/javadetails/java-0014.html
Assuming no better communication method is available (SOAP, ICE, Sockets, etc), I'd call the executable using Runtime.exec(). JNI can be used to interface directly, but I wouldn't recommended it. No you can't put an executable in the jar. Well you can, but you can't run it, since the shell doesn't know how to run it.
You may also want to look at the Java Native Access API (JNA).
To answer your final question, you can't run an executable from within your jar.
However, you can store it within your jar and extract it to a temporary directory/file prior to running it (check for its presence the first time and extract if necessary). This will simplify your distribution somewhat, in that you only have the jar to distribute, and ensures that you're running an executable that matches your jarred Java code.