Calling an (External) Java Program

I know how to call methods from external classes, but how do I launch a self-contained program from one of my applets?
DL

Have tried searching, but it takes a long time on this
connection - the best DialUp speed I can get is 28.8
and most of the time is 14.4.Well, you managed to download the SDK so why not the documentation? It must be hard to work without it.
To start an external application try one of the exec methods of java.util.Runtime.

Similar Messages

  • Execute an external java program with Runtime, problem with classpath

    Hi,
    I m calling an external java program by the command:
    Runtime.getRuntime().exec("java -classpath \"library/*\" org.mypackage.TestMainProgram param1 c:/input/files c:/output/files");All my classes are stored in the relative directory "library", and it contains ONLY .jar files. However, I keep getting errors like:
    "java.lang.NoClassDefFoundError: library/antlr/jarCaused by: java.lang.ClassNotFoundException: library.antlr.jar     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)     at java.security.AccessController.doPrivileged(Native Method)     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)Could not find the main class: library/antlr.jar. Program will exit.Exception in thread "main" where "antlr.jar" is a jar file in "library". It is there but still the program keeps complaining it cannot be found. The problem applies to any jars in "library", ie.., if i have "mylib.jar" then it will complain "NoClassDefFoundError: library/mylib/jar".
    Could anyone give some pointers please?
    Many thanks!
    Edited by: 836590 on 14-Feb-2011 09:03

    836590 wrote:
    Hi,
    I m calling an external java program by the command:
    Runtime.getRuntime().exec("java -classpath \"library/*\" org.mypackage.TestMainProgram param1 c:/input/files c:/output/files");All my classes are stored in the relative directory "library", and it contains ONLY .jar files. However, I keep getting errors like:
    "java.lang.NoClassDefFoundError: library/antlr/jarCaused by: java.lang.ClassNotFoundException: library.antlr.jar     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)     at java.security.AccessController.doPrivileged(Native Method)     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)Could not find the main class: library/antlr.jar. Program will exit.Exception in thread "main" where "antlr.jar" is a jar file in "library". It is there but still the program keeps complaining it cannot be found. The problem applies to any jars in "library", ie.., if i have "mylib.jar" then it will complain "NoClassDefFoundError: library/mylib/jar".
    Could anyone give some pointers please?
    Many thanks!
    Edited by: 836590 on 14-Feb-2011 09:03First, if you run from the command line
    java -classpath "library/*" org.mypackage.TestMainProgram param1 c:/input/files c:/output/filesfrom the parent directory of library, does it work?
    Despite what I said to Kayaman about Runtime.exec not expanding the asterisk, it looks like that's what's happening, so that you're getting
    java -claspath library/aaaa_something_before_antlr.jar library/antlr.jar library/bbb.jar library/ccc.jar  org.mypackage.TestMainProgram param1 c:/input/files c:/output/filesThat is, it *is* expanding the asterisk to a list of files in the directory, and the first one is being taken as the classpath, and the second one--library/antlr.jar is being taken as the class to execute. I'm certain this doesn't happen on Linux, so it must be a Windows thing.
    Two suggestions:
    1) Try single quotes instead of double.
    2) Try the exec that takes an array
    Runtime.getRuntime().exec(new String[] {"java", "-classpath", "'library/*'", "org.mypackage.TestMainProgram", "param1", "c:/input/files", "c:/output/files");Edited by: jverd on Feb 14, 2011 9:41 AM

  • Work with result of a select in an external Java Program

    Hi!
    i would like work with a field of a select in a external java program. I give you an example:
    i want copy a table into another table, but i want do a little modification (before insert action) in one parameter via Java class wich parameter is a field in the select.
    Example:
    i've two tables:
    TABLE_BACK (ID, CARACT)
    TABLE_NEW (ID, CARACT)
    and i've a java Method in an external class com.upc.myClass.modifyCaract(String paramS)
    Then, before insert a row in table_new, i want do a transformation in Caract field from table_back. I want do something like this:
    INSERT INTO TABLE_NEW (ID, NAME) ( SELECT ID, <%=com.upc.myClass.modifyCaract('I WANT HERE CARACT FIELD FROM TABLE_BACK') FROM TABLE_BACK )
    is it possible? how can i do it?
    Thanks!!
    Message was edited by:
    valdomir

    Hola Valdomir,
    Que tal estas? Ya ha empezado el calor en Barcelona ? jejejejejejej
    Well, I think to be possible do what you need.
    1) In a procedure step, at source tab query the values, something like:
    select caract as MY_CARACT from TABLE_BACK
    2) at target tab, use the tags "<@ @>" to import the java class (after put it in the correct ODI directory).
    3) at same target tab, after the tag just write (as your example):
    INSERT INTO TABLE_NEW (ID, NAME) ( SELECT ID, <@=com.upc.myClass.modifyCaract('I #MY_CARACT) FROM TABLE_BACK )@>
    I think this will be enough....
    Un saludo,
    Cezar Santos

  • Running external java program

    Hi all,
    I need to run an external java program from my application.
    The external program can be executed command prompt as follow
    c:\> java -classpath SDMetrics.jar sdmetrics.SDMetrics and another argument
    Since I use the output of the above command , I prefer to do that as a part of my application, in which the external program will be run automatically in my application.
    Any help will be appreciated
    zara 75

    Yeah you can use Runtime.exec (or, if you're using JDK 1.5, ProcessBuilder) to exec the program as a separate process.
    Read this about it:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Java stored procedure vs. PL-SQL vs. external java program

    Hi,
    I'm using a stored procedure for running a query and a few consequent updates. Currently I'm using Java stored procedure for that, which was my choice for simplicity on one hand, and running with the DB on the other.
    In my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.
    Any experiences? recommendations?
    Thanks,
    Dawg

    In my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.This isn't strange at all. See: Oracle's JVM (Aurora) is an independent Java Virtual Machine implementation, in accordance to specification. It implements all necessary parts of it (I think so). When you use an external JVM (I assume it's Sun's HotSpot JVM) you use completely different product. It is implemented in different way, it has many different code parts.
    One of the biggest differences between Oracle's JVM and Sun's JVM is [Just-in-Time compiler|http://en.wikipedia.org/wiki/Just-in-time_compilation]. Oracle has implemented it only in the 11g version of database, i.e. 2 years ago, while Sun performed it back in 2000 and continues to improve it for the last 9 years. That would explain obvious differences between Java program inside and outside the DB: they are executed in absolutely different worlds. Diffs could be up to 10x times or more - that's not unusual.
    If you are on 10g and want to compare performance of stored Java procedure vs external program, then you might use additional command-line instruction for external program to disable JIT:
    -XintPS. I wouldn't use Java for your task - that's a total overkill. Use simple SP instead.

  • How to call another directory java program?

    Hi All,
    For Example:
    My program is here in two directories.Let Think that directory names like A and B.
    Let Program names like Aprog(A directory) and Bprog(B directory).
    I want to call Aprog to Bprog method.
    How to call?
    Plz., help me ASAP.
    --Mohan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    My program is here in two directories.Let
    Think that directory names like A and B.
    It's more complicated than that. A java program consists of multiple .class files. In general you have one or more "trees" of directories of .class files, where the structure of the tree reflects the package structure. So a the class file for "org.dingbat.Thingy" is <basedir>/org/dingbat/Thingy.class where <basedir> is some directory on the class path.
    So referencing one class from another in different directories requires that the source provides the "fully qualified name" of the class (usually on an import) and making sure that, if it's in a different class file tree, both base directories are on the class path.

  • Calling a external Java method from JSP - using Tomcat server

    Hi all,
    I am trying to call a method in an external Java file from my JSP. I am using Tomcat server.
    I have my class within the package package "mypackage" and it is called myclass.class. It has only one static method mymethod() which reads from a file and writes to a file.
    I compiled the java class and I put the class file under webapps/ROOT/web-inf/classes/mypackage/myclass.class
    I am trying to say something like this from my JSP file(which is under webapps/ROOT) :
    <%@ page import = "mypackage.myclass"%>
    <% myclass.mymethod(); %>
    I am not instatiating the class as its a static method.
    This is what I get while accessing my jsp file :
    javax.servlet.ServletException: try to access class mypackage.myclass from class org.apache.jsp.index_005ftest_jsp
    To put my problem in a nutshell, Can someone guide me how to access a method of an external class from a JSP page? I have a bunch of pages doing the same operation so I thought I would have it in a method and call it from every page. Even though I tried to put the file under web-inf/classes, The JSP is not able to see the class.
    Please help.
    Thanks
    -Uday

    I have a situation that is a bit similar. I have successfully used beans for storing methods used in JSPs and used by other methods in the same class as was suggested above. Now I would like to break some methods into another (utility) class since they are lower level and can be used by lots of things. They are for database operations (given a String query and String dbname, it queries and returns ResultSet for example). I want to have them in a separate class for reusability and OOP.
    I am having problems calling those public static methods in the public class from my bean that communicates with the JSP. I can't compile the class that calls the method in the database ops class. I get an error like :
    loginHelper.java:45: cannot find symbol
    symbol : variable sqlHelper
    location: class dbHelperBean.loginHelper
    and when I include the package name in the call I get
    loginHelper.java:45: cannot find symbol
    symbol : class sqlHelper
    location: package dbHelperBean
    That's strange since the package of both classes is dbHelperBean and the class is indeed called sqlHelper. I tried to compile it in the same directory as sqlHelper as well. What am I doing wrong?
    Thanks for any help.

  • How to call stand Alone java program from jsp

    Hello all...
    I want to use the stand alone java program in jsp page. I compiled the java program and place the class file in classes folder under web-inf. But when i try to instantiate the java class inside jsp it is not recognizing the class. Where might be the problem
    Plz help....
    Shamim

    hi , this is dheeraj.. i need to know that how to execute java code and class in jsp.. if anyone know about if bt tell me.. i just know that we can use java code by java beans in jsp.. if you know any knowledge regarding this topic please send me.....

  • Problems calling SOAP in JAVA program

    Hello Experts,
    I'm quite new to using SOAP. I just want to ask how to call SOAP in JAVA specifically NetBean. I already created a webservice using the WSDL a created in SAP XI but problem is when I'm trying to invoke the webservice I always get error "401 Unathorized". Is there a way to specify the user name and password when calling the webservice via JAVA code?
    Error Message:
    Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 401: Unauthorized
    Sample Code:
    public class Main {
    @param args the command line arguments
        public static void main(String[] args) throws UnsupportedEncodingException {
            ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT Req = new ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT();
            Req.setCompanyCode(" ");
            Req.setCustomerNumber("00110");
            RespCustDetailsDT cdwsMI = cdwsMI(Req);
            System.out.println("Customer :" + cdwsMI.getCustomerNumber());
            System.out.println("Name     :" + cdwsMI.getName());
            System.out.println("Street   :" + cdwsMI.getStreet());
            System.out.println("Coutnry  :" + cdwsMI.getCountry());
            System.out.println("City     :" + cdwsMI.getCity());
            System.out.println("MSG Type :" + cdwsMI.getMessageType());
            System.out.println("Message  :" + cdwsMI.getReturnMessage());
        private static RespCustDetailsDT cdwsMI(ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT reqCustomerNoMT) {
            ph.co.amkor.atp.ppmodule.synch.CDWSMIService service = new ph.co.amkor.atp.ppmodule.synch.CDWSMIService();
            ph.co.amkor.atp.ppmodule.synch.CDWSMI port = service.getCDWSMIPort();
            return port.cdwsMI(reqCustomerNoMT);
    SAP Netweaver Information
    Session Information
    Application:
    Design: Integration Builder
    User:
    aafri
    Logon Language:
    Korean
    Server:
    atpxisd01_XD1_01
    Server Node:
    server0
    Runtime Environment
    Java version:
    1.4.2_12
    Java vendor:
    Sun Microsystems Inc.
    Version
    Service pack:
    12
    Release:
    NW04S_12_REL
    Latest change:
    29423
    Sync time:
    ${sync.time}
    Regards,
    Alfred

    Hello John Wu,
    Points were given.
    The code you gave me worked. Thanks! but now I'm having another error below. It seems that it did not returned anything at all cause cdwsMI object is null.
    Error:
    Exception in thread "main" java.lang.NullPointerException
            at xiwebservice.Main.main(Main.java:31)
    Java Result: 1
    Line were error happened:
    public class Main {
    @param args the command line arguments
        public static void main(String[] args) throws UnsupportedEncodingException {
            ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT Req = new ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT();
            Req.setCompanyCode(" ");
            Req.setCustomerNumber("00110");
            RespCustDetailsDT cdwsMI = cdwsMI(Req);
            +System.out.println("Customer :" + cdwsMI.getCustomerNumber());+
            System.out.println("Name     :" + cdwsMI.getName());
            System.out.println("Street   :" + cdwsMI.getStreet());
            System.out.println("Coutnry  :" + cdwsMI.getCountry());
            System.out.println("City     :" + cdwsMI.getCity());
            System.out.println("MSG Type :" + cdwsMI.getMessageType());
            System.out.println("Message  :" + cdwsMI.getReturnMessage());
        private static RespCustDetailsDT cdwsMI(ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT reqCustomerNoMT) {
            ph.co.amkor.atp.ppmodule.synch.CDWSMIService service = new ph.co.amkor.atp.ppmodule.synch.CDWSMIService();
            ph.co.amkor.atp.ppmodule.synch.CDWSMI port = service.getCDWSMIPort();
            BindingProvider prov = (BindingProvider) port;
            prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "aafri");
            prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "betanew3");
            return port.cdwsMI(reqCustomerNoMT);
    Regards,
    Alfred

  • How to call 'WordPad' from java program........

    The following code will open 'Notepad'
    Runtime runt = Runtime.getRuntime();
    Process pr = runt.exec( "notepad" );likewise, I want to open 'Wordpad'
    Runtime runt = Runtime.getRuntime();
    Process pr = runt.exec( "wordpad" );The above two line code, compiles successfully, but it doesn't give the correct result.
    If I give 'wordpad' in start->run->'wordpad', in windowXP means, the Runtime executer opens 'WordPad',
    can anyone give the solution to open WordPad from Java Programming.
    thanks
    Sarwan_Gres

    Try this:
            Runtime runt = Runtime.getRuntime();
            Process pr = runt.exec("cmd /c start wordpad");

  • CPIC error when calling a external c program

    Hi All,
    i Have a scenario where we call a C-Program(RFC api) to connect to and external system thru tcp/ip.
    The issue here is when we call the c program from ABAP we get the below error in files
    dev_rfc0
    Trace file opened at 20091222 094649 TAIST, REL 46D,0,2464, VER 3
    ======> CPIC-CALL: 'ThSAPCMRCV' : cmRc=20 thRc=223
    CPIC program connection ended (read error)
    Error RFCIO_ERROR_SYSERROR in abrfcpic.c : 2961
    CPIC-CALL: 'ThSAPCMRCV' : cmRc=20 thRc=223
    CPIC program connection ended (read error)
    dev_w0
    Tue Dec 22 09:46:49 2009
    ***LOG R49=> tskh_receive, CPIC-Error (020223) [thxxhead.c   6003]
    ***LOG R5A=> tskh_receive, CPIC-Error (80600115) [thxxhead.c   6008]
    ***LOG R64=> tskh_receive, CPIC-Error ( CMSEND(SAP)) [thxxhead.c   6013]
    RFC 2959  CONVID 80600115
    CMRC=20 DATA=1 STATUS=1 SAPRC=223 ThSAPCMRCV
    RFC> ABAP Programm: ABAPXXXX (Transaction: SE38)
    RFC> User: abc (Client: 300)
    RFC> Destination: APIRFC (handle: 1, convid , {4B2E49E2-A088-0082-E100-80003517BA61})
    RFC> Called function module: RFC_API
    dev_rd
    Tue Dec 22 09:46:49 2009
    ***LOG S23=> GwDisconnectClient, client disconnected (029) [gwxxrd.c     10609]
    ***LOG S74=> GwDisconnectClient, client disconnected ( ijkl211) [gwxxrd.c     10620]
    ***LOG S0R=> GwDisconnectClient, client disconnected () [gwxxrd.c     10636]
    ***LOG S0I=> GwDisconnectClient, client disconnected ( interfac) [gwxxrd.c     10657]
    In sm21
    R49 Communication error, CPIC return code 020, SAP return code 223
    Can any one help me find wat might be the cause of this issue.We are using SAP R/3 and OS is AIX 5.3
    Thanks,Rajesh

    Dear Rajesh,
    This depends on what your program does. Based on the error message, it looks like the program ends abnormally, as the gateway writes an error while attempting to read/write data from the connection to the program. With what you have given, the error does not seem to lie with the SAP side. You will have to check your program, e.g. using a debugger.
    Best Regards,
    Tim

  • Calling an external cobol program

    I have a web page that passes and retrieves a data string to an activeX object that in turn calls a cobol program that does all the work. Is it possible to do this with Application Express?
    Message was edited by:
    user511722

    I don't know much about COBOL, but if you can fire the COBOL program from the command line of the ApEx host, you can also use DBMS_SCHEDULER with the EXECUTABLE option.
    Search the PL/SQL forum with the above uppercase keywords for examples of how to write the procedure call.
    I'm assuming you are using 10G.

  • Making telehone calls from a java program

    Hi folks,
    I am developing an application that allows to make calls to certains specifc numbers. Actually calls should be made from the java file, Please advise me which java technology will be suitable for the mentioned.
    Thanks in advance.
    Regards,
    Koijam

    MIDlet#platformRequest(...)

  • Calling external Java from ABAP using JCo?

    Does anyone know if one can use JCo to write a server application that can be called from ABAP.
    We are presently using JCo to communicate from Java to SAP.
    But we need to call an external Java program from within ABAP.
    Is this possible?
    Thanks for any input.
    Fred

    Hi Gregor,
    I was hoping you would reply to this -- these posted messages had been here for quite sometime now.
    Anyway, here's the case. Our Basis team is installing the JCo in our SAP development server. This is our first time to implement this technology, so no one has a clue at all.
    Got a couple of questions for you...
    1. What do we need the JDK for? Is it mainly for editing, running, and compiling java files (e.g. Example5.java)?
    2. Does the JDK need to be installed at the SAP server as well? Or it doesn't matter, as long as the java files will be accessible from where it was installed at?
    Thanks for any response!

  • Sending POSIX signal to an external subprocess from a java program

    I'm programing in forte for java under linux-mandrake, I've execute an external subprocess with the runtime and Process clases, I need to send the 2� POSIX signal to this external subprocess, I mean de SIGINT signal, I know that you can send a signal from a shell just doing:
    Kill -2 pid // the SIGINT signal is the 2 POSIX signal
    I know that there is another system-call like : kill(int signal, int pid) that any one can send from a c program.
    Althought I don't know how can I get the pid of a suprocess, because I Know that there is the systemcall in c like:
    int getpid() wich gives the pid of the current process, but I need to have the pid of a subprocess not the current one.
    The thing is that I do not know how can I do it from a java program, I mean that to send a signal to a subprocess it will work using system-calls, but I do not know if I can insert system call in a java program, I've been thinking about doing it using a linux script like:
    #!bin/bash
    $a = pidof /home/maude-linux/bin/maude.linux
    # this is the path of the process wich is running
    kill -2 a$
    and the run this script from a java program doing an exec(sh script.bin)
    but by the moment I must be doing something wrong in the script because I find mistake in it, it gives me mistake in the assign sentence , I mean:
    $a = pidof /home/maude-linux/bin/maude.linux
    # this is the path of the process wich is running
    I'm not used to program shell scripts, perhaps I'm doing something wrong, is there something wrong in this sentence?.
    I would aprecciate some help about this, or if somebody have some idea how to do it in java, I repeat I need to send a signal to a external subprocess wich is launched from a java program by the process and runtime clases, and I need to send a SIGINT signal to the subprocess, I hope that some body can give some suggestion or some code explaining the situation

    Are the portions of bash-code verbatim in your post?
    When yes, they look suspicious!
    Instead of
    #!bin/bash
    #!/bin/bash
    would be better.
    $a = pidof /home/maude-linux/bin/maude.linux
    does not look good either.
    If you have command "pidof" telling the pid based on the path name of the executable passed to it as its argument, you can have the output of this program in a shell script like this:
    a=$( pidof /home/maude-linux/bin/maude.linux )
    Then through $a you will refer to the value of the variable "a":
    kill -SIGINT $a
    A pidof script could look like this (apart from error handling):
    ps -ef|awk '{if (NF>=8 && $8=="'"$1"'") print $2;}'
    This works for me; your mileage may vary.

Maybe you are looking for