Running Matlab code from java code

Ok so I need to make a java gui interface to run Matlab code. After a lot of search I am aware of three approaches,the com.mathworks.jmi package, JNI and i/o streams. So as far as the first approach I cannot find that package nowhereto downlaod, so please if anyone knows where to find it, or why I cannot find it... As far as the second and third approach, I need this to run on both linux and windows so JNI is the only way. So first of all if someone has another approach to suggest, I would like to hear! So I have found code to do this but it is not working and the problem is that there is c code in all this, and my c knowledge is not good at all, so as you have probably understand this is more like a c problem than java, but I'm not completely sure. Anyway I'm posting all the code I use, then the commands I used to compile it and at last the problem.
Engine.java
package MatlabNativeInterface;
import java.io.*;
* <b>Java Engine for Matlab via Java Native Interface (JNI)</b><br>
* This class demonstrates how to call Matlab from a Java program via
* JNI, thereby employing Matlab as the computation engine.
* The Matlab engine operates by running in the background as a separate
* process from your own program.
* <p>
* Date: 04.04.03
* <p>
* Copyright (c) 2003 Andreas Klimke, Universit&#65533;t Stuttgart
* <p>
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* <p>
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
* @author W. Andreas Klimke, University of Stuttgart
*         ([email protected])
* @version 0.1
public class Engine {
     * Calls the function <code>engOpen</code> of Matlab's C Engine library.
     * Excerpts from the Matlab documentation:
     * "On UNIX systems, if startcmd is NULL or the empty string,
     * <code>engOpen</code> starts MATLAB on the current host using the
     * command <code>matlab</code>. If startcmd is a hostname, <code>engOpen
     * </code> starts MATLAB on the designated host by embedding the specified
     * hostname string into the larger string:
     * <code>rsh hostname \"/bin/csh -c 'setenv DISPLAY\ hostname:0; matlab'\"
     * </code>. If startcmd is any other string (has white space in it, or
     * nonalphanumeric characters), the string is executed literally to start
     * MATLAB. On Windows, the startcmd string must be NULL."<br>     
     * See the Matlab documentation, chapter "External Interfaces/API
     * Reference/C Engine Functions" for further information.
     * @param startcmd The start command string.
     * @throws IOException Thrown if starting the process was not successful.
  public native void open(String startcmd) throws IOException;
      * Calls the function <code>engClose</code> of Matlab's C Engine
      * library.     This routine allows you to quit a MATLAB engine session.
      * @throws IOException Thrown if Matlab could not be closed.
     public native void close() throws IOException;
     * Calls the function <code>engEvalString</code> of Matlab's C Engine
     * library. Evaluates the expression contained in string for the MATLAB
     * engine session previously started by <code>open</code>.
     * See the Matlab documentation, chapter "External Interfaces/API
     * Reference/C Engine Functions" for further information.
     * @param str Expression to be evaluated.
     * @throws IOException Thrown if data could not be sent to Matlab. This
     *                     may happen if Matlab is no longer running.
     * @see #open
  public native void evalString(String str) throws IOException;
      *  Reads a maximum of <code>numberOfChars</code> characters from
      * the Matlab output buffer and returns the result as String.<br>
      * If the number of available characters exceeds <code>numberOfChars</code>,
      * the additional data is discarded. The Matlab process must be opended
      * previously with <code>open()</code>.<br>
      * @return String containing the Matlab output.
      * @see #open
      * @throws IOException Thrown if data could not be received. This may
      *                     happen if Matlab is no longer running.
  public native String getOutputString(int numberOfChars);
      * Initialize the native shared library.
  static {
         System.loadLibrary("Engine");//I have changed this
     //System.loadLibrary("engineJavaMatlab");
     System.err.println("Native Matlab shared library loaded.");
}Engine.c
#include <jni.h>
#include "MatlabNativeInterface_Engine.h"
#include <stdio.h>
#include "engine.h"
#define DEFAULT_BUFFERSIZE 65536
Engine* ep;
char outputBuffer[DEFAULT_BUFFERSIZE];
JNIEXPORT void JNICALL
Java_MatlabNativeInterface_Engine_open(JNIEnv *env, jobject obj, const jstring startcmd) {
  const char *c_string = (*env)->GetStringUTFChars(env, startcmd, 0);
  if (!(ep = engOpen(c_string))) {
    jclass exception;
    (*env)->ReleaseStringUTFChars(env, startcmd, c_string);
    exception = (*env)->FindClass(env, "java/io/IOException");
    if (exception == 0) return;
    (*env)->ThrowNew(env, exception, "Opening Matlab failed.");
    return;
  (*env)->ReleaseStringUTFChars(env, startcmd, c_string);
     /* indicate that output should not be discarded but stored in */
     /* outputBuffer */
  engOutputBuffer(ep, outputBuffer, DEFAULT_BUFFERSIZE);
JNIEXPORT void JNICALL
Java_MatlabNativeInterface_Engine_close(JNIEnv *env, jobject obj) {
     if (engClose(ep) == 1) {
       jclass exception;
    exception = (*env)->FindClass(env, "java/io/IOException");
    if (exception == 0) return;
    (*env)->ThrowNew(env, exception, "Closing Matlab failed.");
    return;
JNIEXPORT void JNICALL
Java_MatlabNativeInterface_Engine_evalString(JNIEnv *env, jobject obj, const jstring j_string) {
  const char *c_string;
     c_string = (*env)->GetStringUTFChars(env, j_string, 0);
  if (engEvalString(ep, c_string) != 0) {
       jclass exception;
    exception = (*env)->FindClass(env, "java/io/IOException");
    if (exception == 0) return;
    (*env)->ThrowNew(env, exception, "Error while sending/receiving data.");
  (*env)->ReleaseStringUTFChars(env, j_string, c_string);
JNIEXPORT jstring JNICALL
Java_MatlabNativeInterface_Engine_getOutputString(JNIEnv *env, jobject obj, jint numberOfChars) {
  char *c_string;
     jstring j_string;
     if (numberOfChars > DEFAULT_BUFFERSIZE) {
          numberOfChars = DEFAULT_BUFFERSIZE;
  c_string = (char *) malloc ( sizeof(char)*(numberOfChars+1) );
     c_string[numberOfChars] = 0;
  strncpy(c_string, outputBuffer, numberOfChars);
     j_string = (*env)->NewStringUTF(env, c_string);
     free(c_string);
  return j_string;
}MatlabNativeInterface_Engine.h (as produced by javah)
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class MatlabNativeInterface_Engine */
#ifndef _Included_MatlabNativeInterface_Engine
#define _Included_MatlabNativeInterface_Engine
#ifdef __cplusplus
extern "C" {
#endif
* Class:     MatlabNativeInterface_Engine
* Method:    open
* Signature: (Ljava/lang/String;)V
JNIEXPORT void JNICALL Java_MatlabNativeInterface_Engine_open
  (JNIEnv *, jobject, jstring);
* Class:     MatlabNativeInterface_Engine
* Method:    close
* Signature: ()V
JNIEXPORT void JNICALL Java_MatlabNativeInterface_Engine_close
  (JNIEnv *, jobject);
* Class:     MatlabNativeInterface_Engine
* Method:    evalString
* Signature: (Ljava/lang/String;)V
JNIEXPORT void JNICALL Java_MatlabNativeInterface_Engine_evalString
  (JNIEnv *, jobject, jstring);
* Class:     MatlabNativeInterface_Engine
* Method:    getOutputString
* Signature: (I)Ljava/lang/String;
JNIEXPORT jstring JNICALL Java_MatlabNativeInterface_Engine_getOutputString
  (JNIEnv *, jobject, jint);
#ifdef __cplusplus
#endif
#endifand a Main.java
import MatlabNativeInterface.*;
import java.io.*;
* Demonstration program for connecting Java with Matlab using the Java
* Native Interface (JNI). Wrapper functions access Matlab via Matlab's
* native C Engine library.
public class Main {
     public static void main(String[] args) {
          Engine engine = new MatlabNativeInterface.Engine();
          try {
               // Matlab start command:
               engine.open("matlab -nosplash -nojvm");
               // Display output:
               System.out.println(engine.getOutputString(500));
      // Example: Solve the system of linear equations Ax = f with
               // Matlab's Preconditioned Conjugate Gradients method.
               engine.evalString("A = gallery('lehmer',10);");  // Define Matrix A
               engine.evalString("f = ones(10,1);");            // Define vector f
               engine.evalString("pcg(A,f,1e-5)");              // Compute x
               // Retrieve output:
               System.out.println(engine.getOutputString(500));
               // Close the Matlab session:
               engine.close();
          catch (Exception e) {
               e.printStackTrace();
}so I compile them with:
javac -d classes @files.txt
javah -classpath classes MatlabNativeInterface.Engine
cc -shared -I/usr/java/jdk1.6.0_06/include/ -I/usr/java/jdk1.6.0_06/include/linux/ -I/usr/local/share/matlab7.6/extern/include/ Engine.c -o libEngine.soso everything gets compiled well and then I run Main:
/javas/classes/_>mv libEngine.so classes/
/javas/classes/_>cd classes/
/javas/classes/_>java -Djava.library.path=. Main
Exception in thread "main" java.lang.UnsatisfiedLinkError: /javas/classes/libEngine.so: /javas/classes/libEngine.so: undefined symbol: engOpen
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1030)
        at MatlabNativeInterface.Engine.<clinit>(Engine.java:99)
        at Main.main(Main.java:11)So... please help!

I need this to run on both linux and windows so JNI is the only wayHuh? Streams in general work on windows and linux. So maybe some more specific info
about what you mean by "i/o streams."
I am aware of three approachesA fourth approach is to write an application in C which communicates with Matlab directly
and then uses some idiom such as sockets to allow communication to java. This would generally
be the method that I would prefer over all others since it makes debugging and testing easier.
undefined symbol: engOpenSomehow you are missing a library (nothing specific to to with JNI nor java) in you JNI code.
Odd error since I would normally expect something else. Try using System.load/loadLibrary() in java to explicitly load the Matlab
library (or libraries) before your JNI library. The load/LoadLibrary calls don't care if it is JNI or not.

Similar Messages

  • Running sqlplus scripts from Java code?

    hi
    I need to programmatically run sqlplus scripts from Java code on a machine that doesn't have sqlplus installed.
    Is there any Java class library available for doing this?

    The Ant approach could probably work for me, thanks for the tip.
    The setup seems rather complex however, given the simplicity of the task. I would prefer just running a Java based SQL*Plus from in a separate process or doing this via an API that would allow me to run SQL*Plus scripts (parse script, substitute variables, run statements).
    Oracle SQL Developer v1.1 appears to include an API that does exactly this.
    The ScriptParser, Substitution and SQLPLUS classes in the oracle.dbtools.raptor.scriptrunner package (oracle.sqldeveloper.jar) seem to do just what I need based on my tests.
    Can I use these classes for this purpose in my application? Is repackaging allowed?
    Does Oracle have any plans for releasing this sort of functionality separately e.g. as part of the Instant Client?

  • Running .jar files from Java code

    Hi.
    I am designing a sort of platform to run some games which are saved in .jar files. Basically this platform is a menu from which the user can select the game which he/she wants to run. It also has the feature of adding new games.
    Is is possible to run the .jar file from within java code?
    Thanks for any help!
    Krt_malta

    Just list the jar in the classpath list and call the class in the jar.

  • Running .bat files from java code

    Dear Forum,
    I have seen numerous postings on the web about this question, still I have found no answer that works (for me)
    I�m trying to run a simple .bat file from a piece of java code , however it does not work. No error message , but still.
    Does anyone have a tip?
    best regards
    temuj
    try{
                String cmd = "cmd.exe C:\\mybat.bat";
                Runtime.getRuntime().exec(cmd);
    catch(IOException e){System.out.println("ERROR: "+e);}Message was edited by:
    temujin

    "cmd.exe C:\mybat.bat" is being passed to the OS for execution
    what happens when in a terminal/dos window you execute letter for letter:
    cmd.exe C:\mybat.bat
    The output will be identical to what is happening when java makes this call.

  • Run a program from java code

    I want to run this program from my java code,
    In Linux(ubuntu) I write this command to open the program window
    $ paraFoam -case /home/saud/OpenFOAM/OpenFOAM-1.5/run/tutorials/icoFoam/cavity/In my java code I wrote it like this("/home/saud/OpenFOAM/OpenFOAM-1.5/bin/" is the path of the program):
    String command = "/home/saud/OpenFOAM/OpenFOAM-1.5/bin/paraFoam " +
              "-case /home/saud/OpenFOAM/OpenFOAM-1.5/run/tutorials/icoFoam/cavity/";
    final Process myProcess = Runtime.getRuntime().exec(command);
    BufferedReader buf = new BufferedReader(new InputStreamReader(
              myProcess.getInputStream()));
    String line;
    while ((line = buf.readLine()) != null) {
         System.out.print(String.format("%s\t\n", line));
    buf.close();
    int returnCode = myProcess.waitFor();
    System.out.println("Return code = " + returnCode); Return code = 0
    but the program is not opening
    Edited by: Saud.R on Apr 11, 2009 3:37 AM

    Welcome to the Sun forums.
    I am not sure of the answer to your question, but people who use Processes regularly, warn other users to ensure they are also doing something with the error stream of the process, otherwise it can hang as you describe.

  • Running a command from java code

    hi all,
    There is a command
    "java -jar selenium-server.jar -interactive"
    which i am running through command prompt after going to D:\MyFolder\Examples .
    i want to execute this command using java code .please help

    subratjyetki wrote:
    please answer in detail or if posible can u give the code for thisOnce more -
    The detail is given in the reference. Why don't you read it?
    I could give you the code but it will cost you �100 per hour.

  • Running mysqldump query from java code

    Hello,
    I m making a program I want to take a backup of database on a click of a button for which i want to execute this query :
    "mysqldump --user=root --password=root --opt dbname>c:\backup.sql"
    and my code is :
    String command = "cmd /c start";
    String[] env = new String[]{"mysqldump","--user=root", "--password=root",
    "--opt", "njitsurvey", "<", "c:\\backup_db.sql" };
    File dir = new File("C:/Program Files/MySQL/MySQL Server 5.0/bin/");
    Process p1 = Runtime.getRuntime().exec(command, env, dir);
    My problem is my command is running and going in to the directory also but not running my query and i m not getting and error also
    Edited by: purva on Aug 7, 2008 11:56 PM

    You need to print the content of the process error stream ( p1.getErrorStream() ) . It would also be worth you while reading http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .
    Also, you seem to think that setting the working directory toFile dir = new File("C:/Program Files/MySQL/MySQL Server 5.0/bin/");makes this the directory from which 'mysqldum' is found. It is not. The directory containing the executable has to on the PATH. The working directory is where the process looks for and creates data files if the full path to the files is not provided.
    Edited by: sabre150 on Aug 8, 2008 10:41 AM
    Also, you seem to think that the 'env' is the command executed! It is not. It the set of environment variables. You need to put the whole of the command as the first argument.
    Edited by: sabre150 on Aug 8, 2008 10:46 AM

  • Generate IDL from Java Code, Classes, UML, etc?

    Hi,
    is is possible to generate IDL code from Java Code, Classes, UML, ... using JDeveloper?
    I know this is somewhat reverse engeneering, but it would speed up the migration of our existing Java project...
    Thanks,
    Johan

    Hi,
    is is possible to generate IDL code from Java Code, Classes, UML, ... using JDeveloper?
    I know this is somewhat reverse engeneering, but it would speed up the migration of our existing Java project...Unfortunately it does not. The IDL to Java conversion is handled under the covers by the idl2java.exe included with the database. You might want to search on google for a IDL generator from java source.
    java2iiop (another tool) just generates IIOP stubs from classes and interfaces, but I don't think it creates IDL.
    Rob

  • Ask from Java code if service runs

    Hi,
    i have a service,  com.business.company.navigation.connector
    running as ear on sap portal server.
    Is there a way to ask from Java code if this service is running or not!?
    I found following code which shows how access the portal runtime to get
    default portal services:
    NavigationEventsHelperService helperService = (NavigationEventsHelperService) PortalRuntime.getRuntimeResources().getService(NavigationEventsHelperService.KEY);
    Thanks for any hint.

    Hi,
    i have a service,  com.business.company.navigation.connector
    running as ear on sap portal server.
    Is there a way to ask from Java code if this service is running or not!?
    I found following code which shows how access the portal runtime to get
    default portal services:
    NavigationEventsHelperService helperService = (NavigationEventsHelperService) PortalRuntime.getRuntimeResources().getService(NavigationEventsHelperService.KEY);
    Thanks for any hint.

  • How to call a .bat file from java code?

    How to call a .bat file from java code? and how can i pass parameters to that .bat file?
    Thanks in advance

    thanks for ur reply
    but still i am getting the same error.
    I am trying to run a .bat file of together tool, my code looks like below
    import java.lang.Runtime;
    import java.lang.Process;
    import java.io.File;
    class SysCall{
         public static void main(String args[]){
              String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
              //String path="D://Borland//Together6.2//bin//Together.bat ";
              Runtime r= Runtime.getRuntime(); //Declare the system call
              try{
                   System.out.println("Before batch is called");
                   Process p=r.exec(cmd);
                   System.out.println(" Exit value =" + p.exitValue());
                   System.out.println("After batch is called");
              /*can produce errors which must be caught*/
              catch(Exception e) {
                   e.printStackTrace();
                   System.out.println (e.toString());
    I am getting the below exception
    Before batch is called
    java.lang.IllegalThreadStateException: process has not exited
    at java.lang.Win32Process.exitValue(Native Method)
    at SysCall.main(SysCall.java:17)
    java.lang.IllegalThreadStateException: process has not exited

  • Running bat files in java code

    Hi,
    I am trying to run a .bat file within java code like this.
    Runtime.getRuntime().exec("c:\\Test.bat");
    but no success. Could you please suggest how to run .bat file or simply a
    DOS command from java code.
    thanx in advance
    Deepak Garg.

    try this...
    n reply whether it worked or not......
    import java.util.*;
    import java.io.*;
    import java.net.*;
    try
    Runtime runtime = Runtime.getRuntime();
    Process process ;
    process= runtime.exec("./temp_install");
    //code to print command line replies
    InputStream stderr = process.getInputStream();
    InputStreamReader isr = new InputStreamReader(stderr);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while((line=br.readLine())!=null)
    System.out.println(line);
    catch(Throwable t)
    t.printStackTrace();
    }

  • Problem when connecting locally to Oracle Database 10g from Java code

    Good afternoon,
    I try to connect to my local Oracle 10g from JAVA code. Could somebody tells me what are the 'values' to enter in place of 'value1, value2, value3' in the following:
    final String connectionURLThin = "jdbc:oracle:thin:@value1:value2:value3";
    I tried to put my 'user' and 'pw' credentials I used when connecting with SQL*PLUS:
    value1=my_user_name
    value2=my_pw
    value3=my_schema
    but it doest work. Besides where could have I to put the 'WORKSPACE" name?
    Thanks for any help.
    Claude
    Details:
    ERR MESSAGE----------------------
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/dms/instrument/ExecutionContextForJDBC
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:365)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:854)
    at java.sql.DriverManager.getConnection(DriverManager.java:620)
    at java.sql.DriverManager.getConnection(DriverManager.java:200)
    at javaapplication6.ConnectionExample.driverManager(ConnectionExample.java:138)
    at javaapplication6.Main.main(Main.java:36)
    Caused by: java.lang.ClassNotFoundException: oracle.dms.instrument.ExecutionContextForJDBC
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
    ... 8 more
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)
    ---------------------ERR MESSAGE
    JAVA code------------------it compiles but throw an error when running there -> (*)...
    final String driverClass = "oracle.jdbc.driver.OracleDriver";
    final String connectionURLThin = "jdbc:oracle:thin:@jeffreyh3:1521:CUSTDB";
    final String userID = "scott";
    final String userPassword = "tiger";
    final String queryString = "SELECT" +
    " user " +
    " , TO_CHAR(sysdate, 'DD-MON-YYYY HH24:MI:SS') " +
    "FROM dual";
    public void driverManager() {
    Connection con = null;
    Statement stmt = null;
    ResultSet rset = null;
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection(connectionURLThin, userID, userPassword); // (*) prob here
    stmt = con.createStatement ();
    rset = stmt.executeQuery(queryString);
    rset.close();
    stmt.close();
    } catch (SQLException e) {e.printStackTrace();
    --------------------JAVA JDK 1.6
    My system ------------------------
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production

    Yes, the network connection could not be established. Like the error said.
    What you're asking about is the exact reason, but that could be any number of things and not at all related to code. You could have the wrong host, the wrong port. A firewall could be blocking the outgoing connection, a firewall could be blocking the incoming connection. Etc. etc.

  • Can u access Oracle9i Reports objects from Java Code?

    Hi,
    How can you access Oracle9i Reports (Rel 2) objects like Body, DataSource, Groups etc from Java Code?
    What are the available APIs?
    I went thru the APIs at http://otn.oracle.com/products/reports/htdocs/getstart/docs/Javadocs/oracle/reports/plugin/definition/package-summary.html
    However various constructors stated in these APIs are using classes from "oracle.reports.definition" package which are difficult for me to locate.
    For eg. Report constructor is using oracle.reports.definition.RWReport and there is no API documentation available for RWReport class.
    Please suggest me the site for the above APIs or the method to get a reference to "Report" instance.
    Thanks
    Rakesh.

    Thanks Tugdual for your quick reply.
    Thats exactly what I am trying to do. I want to develop a utility which can have a subset of Report Developer's functionality.
    Currently using Reports Developer & Report Wizard, I can create a report by providing SQL statement and few parameters (like Report Style, Calculated Fields, Template file etc). I want to put all these parameters in a XML file and run my java utility (based on the APIs which I am looking for) which will use these XML parameter file and generate a '.rdf' file.
    Also, could you please suggest me the site for oracle.reports.definition package API or the way to get a reference to oracle.reports.plugin.definition.Report instance.
    Thanks,
    Rakesh

  • Set classpath from java code

    Hi,
    Is it possible to set new classpath from java code? Something like System.setClasspath(String);
    Many thanks
    Miso

    You aren't the first one to wonder whether that would work, so don't call yourself stupid on that account.
    Not taking 15 minutes to set up and run a test to actually see if it works... well, if you really needed the answer, that would be different.

  • How to kill a system process from java code.

    Hi,
    i need to kill or remove windows system process like cmd.exe from java code.
    like removing it from end process in task mgr.
    i tried below code but its not removed.
    is there a better way we can do this.
    killing a system process from java code will create any issues?
       public static void main(String[] args) throws Exception {
       String[] cmd = { "cmd.exe" };
       Process p = Runtime.getRuntime().exec(cmd);
       p.destroy();
    any suggestions or ideas are really appreciated.
    thanks.

    Hi  jtahlborn, mohan
    yes the process is created from my java code. 
    in my code iam creating a process like below and if it is running for a long i need to kill it from java.
    For that " Runtime.getRuntime().exec("taskkill /F /PID " +  7408); " is working fine.
    7408 is my process id in taskmgr created from java and iam manually passing the PID it to kill it.
    But i need to get the PID from java code.
    Thanks for your suggestions.
    Sample Code:
    public static void main(String args[])
            try {
              Process process = Runtime.getRuntime().exec(new String[]{"cmd.exe","/c","start"});        
              Field f = process.getClass().getDeclaredField( "handle");
              f.setAccessible( true);         
              long procHandle = f.getLong( process);
              System.out.println( "prochandle: " + procHandle );
              //Runtime.getRuntime().exec("taskkill /F /PID " +  procHandle);
            } catch( Exception e) {
              e.printStackTrace();

Maybe you are looking for