How to invoke a JAR from Java Swing application?

Hi,
I am trying to start a jar file from the swings application.
I am trying the following code,
String cmd[] = new String[]{"cmd", "java -jar TestJFreeChart.jar"};
try
       Process run = Runtime.getRuntime().exec(cmd);
catch(Exception e)
{}Is anything wrong in the usage?

First try:
"cmd /c java -jar app.jar" or cmd start, because it can't jsut run java.exe, it needs to be
passed to the cmd interpretor witch further calls java.exe, etc
Also read what stevejluke suggested. Its important to know if .waitFor or not.
You wont understand these until you read the tutorial.

Similar Messages

  • How to invoke BPEL process from JAVA API

    Hi Guys
    Any idea if you can tell me how to invoke BPEL process from JAVA API ?
    What to do in BPEL process manager to achieve that?
    Regards
    Deepak

    See http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28981/invoke.htm#sthref1373 and the JavaDocs http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28986/toc.htm.

  • Viewing and printing a PDF file from Java Swing Application

    Hello,
    I need to view and print PDF files from Java Swing Application.How do I do that?I appreciate your help.
    Thank you
    Sumana Somareddy

    If you have a link to the URL pointing to the PDF file, you can allow the browser to open it. Then use the print function of the browser to print the PDF document.
    Regards,
    Tak.

  • How to invoke dos shell from java program

    Hi,
    I'm not able to invoke dos shell from java.
    Can any one help me in this issue.
    I'm providing the source code below:
    try{
    Runtime.getRuntime().exec("cmd.exe")
    catch(IOException e) {
    System.out.println(e.getStackTrace());
    Thanks

    Does it throw a different exception?
    Or does it just do nothing at all?
    It does nothing at all[/b
    Is this a standalone Java app?
    Or a Java Applet running via a webbrowser? [b]It's a standalone application

  • JDev 10.1.3 how to invoke oc4j_remote_deploy.jar from command line?

    Hi, does anyone know how to invoke the JDev 10.1.3 oc4j_remote_deploy.jar from the command line? We have it working for 10.1.2, for automated deployment scripts.
    If I try the same thing for 10.1.3, I get an error.
    See below my command line and the output.
    I think the error is in the Oc4jDcmServlet URL, the format seems to have changed from 10.1.2 to 10.1.3.
    I tried to reverse-engineer by using an HTTP tracer, but that did not help.
    Any help would be much appreciated.
    Regards, Maarten Brugman
    ======================== command line: ==================
    "C:\j2sdk1.4.2_09\bin\java.exe" -Djava.protocol.handler.pkgs=HTTPClient -jar C:\jdev-work\ebrp-new\ear\target\installer\oc4j_remote_deploy.jar http://lnvx0027:29805/Oc4jDcmServletAPI/ oc4jadmin ***** listApplications /oracle/oaedv03/oracle/oas/10.1.3/ontwj2e1013 UNDEFINED UNDEFINED OC4J_OEBRP
    ============ output: ====================================
    Initializing log
    Servlet interface for OC4J DCM commands
    Command timeout defined at 600 seconds
    Executing DCM command...
    Executing command listApplications /oracle/oaedv03/oracle/oas/10.1.3/ontwj2e1013
    UNDEFINED UNDEFINED OC4J_OEBRP
    Command = LISTAPPLICATIONS
    Opening connection to Oc4jDcmServlet
    Setting userName to oc4jadmin
    Sending command to DCM servlet
    **** Could not check HTTP response code
    ** Thread[main,5,main] ** Fri May 11 17:18:13 CEST 2007 ** ** EXCEPTION: java.
    net.SocketException: Unexpected end of file from server
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:822)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:711)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:820)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:711)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:635)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:272
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmClient.isHttpResponseOk(Unknow
    n Source)
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmClient.sendCommand(Unknown Sou
    rce)
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmCommand.execute(Unknown Source
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmCommand.listApplications(Unkno
    wn Source)
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmMain.main(Oc4jDcmMain.java:71)
    #### HTTP response is NOT ok
    Closing connection to Oc4jDcmServlet
    #### DCM command did not complete successfully (-1)
    #### HTTP return code was -1
    ============ end output =================================

    In my opinion, you will succeed in handling linefeeds in output texts by using an <tt><af:outputFormatted></tt> tag in conjuction with a JSF converter that replaces the linefeeds with a <tt>&lt;br></tt> tag in the text. You will have to implement a custom converter class (this is quite simple, see below) and to set it to the <tt>converter</tt> attribute of the <tt><af:outputFormatted></tt>. The converter class should look like:
    public class MyLinefeedConverter implements javax.faces.convert.Converter
      public MyLinefeedConverter() {
      public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return value;
      public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value==null) return "";
        if (value instanceof String) return ((String)value).replace("\n", "<br>");
        return value.toString();
    }In this way the linefeeds in your text values will be replaced by <tt>&lt;br></tt>, which will be rendered by the corresponding <af:outputFormatted> tag as line breaks.

  • How to invoke Bpel process  from java using 'bpel process WSDL'

    I want to call bpel process from java using bpel wsdl.
    could any one point me to any url/sample.
    Thanks
    Nagajyothy

    Hi Seshagiri,
    Thanks for providing links and initial steps to create web service proxy(using Jdeveloper 11g).
    I created a web service proxy.
    provided the needed inputs.
    when I ran the client app, bpel process(has a human task) got invoked but faulted with exception as below
    Operation 'initiateTask' failed with exception 'EJB Exception: : java.lang.ExceptionInInitializerError[[
         at oracle.tip.pc.services.common.ServiceFactory.getAuthorizationServiceInstance(ServiceFactory.java:147)
         at oracle.bpel.services.workflow.task.impl.TaskService.initiateTask(TaskService.java:1159)
         at oracle.bpel.services.workflow.task.impl.TaskService.initiateTask(TaskService.java:502)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
    please help me in solving the above problem.
    Thanks
    Nagajyothy

  • How to Invoke a report from java?

    Hi,
    I am a java / web developer with no reports experience.
    We wish do the following from a java based web application:
    On a web page we have two buttons
    1) Print
    2) Create file.
    We want these two buttons to perform the following tasks:
    1) The print button should run a predefined report with a set of parameters and send the output to a printer.
    2) The Create File button should run a predefined report with a set of parameters and send the output to a rtf file on a temp area, which the java app can pick up for further processing.
    Both actions should be triggered from the web app without the need for users
    to have any knowledge of reports at all.
    We are running ias 9.0.2.3.
    Is the use of the plsql SRW package the best way to achieve this kind of functionality
    or are there other JAVA APIs or any other ways to solve this scenario?
    Any comments appreciated!
    Regards
    Per A Jorgensen

    Hi Per,
    In your submit button's ACTION, the URL that you submit should be like this:
    For printing button:
    http://machine:port/reports/rwservlet?report=...+server=...+userid=...+destype=printer+desformat=...+desname=<printer_name>
    For create file button:
    http://machine:port/reports/rwservlet?report=...+server=...+userid=...+destype=file+desformat=...+desname=<file_name>
    Find the report request methods as syntax in the Publishing Reports Manual (Section 13.2)
    http://otn.oracle.com/documentation/reports.html
    Navneet.

  • How to invoke a webservice from ADF Mobile application.

    Hi,
    I have developed a webservice from a PL/SQL Package in jdeveloper 11.1.1.5.0 by following below link
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/jdev/obe1013jdev/10131/wsfromplsqlpackage/devwsfrom%20plsql.htm#p.
    it went on smooth till i reach " Deploying and Testing the Web Service " section. i could not find the Resources folder in which i have webservices.deploy file in my Project folder as shown in the example
    please let me know how to get this and i want that webservice to be deployed on to weblogic server other than OC4J.
    Kindly someone help me in this regards.
    Thanks in advance.

    Hi,
    Iam not that much familliar with using webmethods Integration server. But generally wen you are using a tool to Create webservices it will generate WSDL(Webservice Description file) and Client access classes. The Client access class contains the code for accessing the webservice. You can develop Clients by importing this class. The other way is you can use the WSDL to connect to the Webservice. WSDL file includes the End point URL (the location where to connect to access the webservice). By connecting to this URL you can access the webservice.
    Few sites which help you in getting more info on Webservices are:
    http://www.w3.org/2002/ws/
    http://www-106.ibm.com/developerworks/webservices/
    http://java.sun.com/webservices/
    You can mail me at [email protected]
    Regards
    Mahen

  • How to run ODI scenario from java?

    I am new to java, need to do some testing on how to invoke ODI scenarios from java.
    Can somebody drop me some simple code?
    Thanks a lot,
    Lei

    Hi there
    1. Start your agent (double click agent.bat)
    2. generate scenario for ur package(right click ur package , select generate scenario)
    3. Add the odi-sdk-invocation.jar file to your java project
    ODIcmdScenario=new OdiCommandScenario();
    ODIConnection=new OdiRepositoryConnection();
    ODIConnection.setOdiUser("ur-username");
    ODIConnection.setOdiPassword("ur-password");
    ODIConnection.setJdbcDriver("Driverdetail");
    ODIConnection.setJdbcUrl("url-details");
    ODIConnection.setJdbcUser("dbusername");
    ODIConnection.setJdbcPassword("dbpass");
    ODIcmdScenario.setScenName("scenarioname");
    ODIcmdScenario.setScenVersion("scenarioversion");
    ODIcmdScenario.setLogLevel(5);
    ODIcmdScenario.setContext("context");
    ODIConnection.setWorkRepositoryCode("repository");
    ODIInvocation = new OdiInvocation("hostname", 20910); //20910 default port
    OdiInvocationResult result=ODIInvocation.invokeCommand(ODIcmdScenario,ODIConnection);
    Hope this helps!
    Cheers

  • Invoke beanshell methods from java

    Hello
    I'm learning beanshell and using it to write scripts that are ran in JDK 6.
    My question is how to invok beanshell methods from java source codes.
    My codes is:
    import javax.script.*;
    public class InvokeFunctions {
    public static void main (String[] args)throws ScriptException, NoSuchMethodException
    ScriptEngineManager sem = new ScriptEngineManager();
    ScriptEngine bshEngine = sem.getEngineByName("beanshell");
    String script = "public void sayHello()"+"{print (\"sayHello() is a method in bsh script\");}";
    bshEngine.eval(script);
    Invocable inbshEngine = (Invocable)bshEngine;
    inbshEngine.invokeFunction("sayHello");
    I defined a method "sayHello()" using beanshell, but i just can't invoke it in Java.
    I got an error msg said:
    Exception in thread "main" java.lang.IllegalAccessError: tried to access method bsh.NameSpace.getThis(Lbsh/Interpreter;)Lbsh/This; from class bsh.engine.BshScriptEngine
    Any one has any idea about it?
    Thanks

    Look at the Javadoc documentation of IllegalAccessError. It says:
    Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.
    Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.
    Maybe recompiling all your sources (make sure you delete all existing *.class files) will help?

  • Invoking a Java swing application via its process id

    I have a Java swing application. What i am trying to do here is that when the user double-clicks the jar file to open it, if the Swing application is already open and is minimized, I need to maximize the open window and make it active.
    I tried using 'jps -l' command in my new instance, and with the help of Runtime.exec() am able to detect whether the application is already running or not, and if running, am able to get the process id and am displaying a message to user indicating the window is already open.
    But how do i maximize the window of an already running application? Is it possible?

    user13333704 wrote:
    I have a Java swing application. What i am trying to do here is that when the user double-clicks the jar file to open it, if the Swing application is already open and is minimized, I need to maximize the open window and make it active. That's not hard to do, but your proposed solution is hard to do. The usual way to have only one instance of a Java application running is this:
    Have the application open a SocketServer on a certain port number. Since only one process can listen on a port, the second instance of the application will fail when it tries to open the SocketServer. When that happens, the second instance should terminate instead of displaying its own GUI. Whether it terminates silently or whether it displays a dialog is up to you.
    If you want the second instance to communicate with the first instance, that's easy because the first instance is listening on the port. So the second instance could connect to that port and send a message to it. In your case the first instance would respond to that message by maximizing its GUI.

  • How to do a dropdownlist in java Swing much like a JMenuBar items

    Hi sir,
    Here i want to know how to do a dropdownlist in java swing much like a JMenuBar items falling from the top to bottom .Here i should not use JMenuBar in any way.
    So that i need to do the dropdownlist by using other feature only.Since i am new to this.I need ur help urgently.Pls do provide the code for this so that i will be so gratefull to u.It is very Urgent.Since i have involved in a project which involves this feature.Pls. do provide the answer as well as the code quickly as possible.
    Thanx
    m.ananthu

    use JComboBox
    http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html

  • How to invoke a servlet from MDB

    Hi,
    Can someone please tell me how to invoke a servlet from MDB. Actually I want to have a MDB that will invoke a servlet that takes arround ~3 minutes to process and send the response back to MDB. Any small code snippet on invoking a servlet.
    Thanks

    nope. this is probably a bad design.
    but here's a hint: whenever you have a question like this, start browsing the javadocs. chances are there's a class that might help you.
    i'd recommend that you look at this:
    http://java.sun.com/javase/6/docs/api/java/net/HttpURLConnection.html
    %

  • How to execute Linux command from Java app.

    Hi all,
    Could anyone show me how to execute Linux command from Java app. For example, I have the need to execute the "ls" command from my Java app (which is running on the Linux machine), how should I write the codes?
    Thanks a lot,

    You can use "built-in" shell commands, you just need to invoke the shell and tell it to run the command. See the -c switch in the man page for your shell. But, "ls" isn't built-in anyays.
    If you use exec, you will want to set the directory with the dir argument to exec, or add it to the command or cmdarray. See the API for the variants of java.lang.Runtime.exec(). (If you're invoking it repeatedly, you can most likely modify a cmdarray more efficiently than having exec() decompose your command).
    You will also definitely want to save the returned Process and read the output from it (possibly stderr too and get an exit status). See API for java.lang.Process. Here's an example
    java.io.BufferedReader br =
    new java.io.BufferedReader(new java.io.InputStreamReader(
    Runtime.getRuntime().exec ("/sbin/ifconfig ppp0").
    getInputStream()));
    while ((s = br.readLine()) != null) {...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to call gnuplot command from java

    Hi there,
    In our course, we are required to develop an GUI for gnuplot. In case you don't know about gnuplot, it's a plotting program and has lots of command. We want to use java and swing, but now we don't know how to call gnuplot command from java, or how to execute a shell command(script) from java.
    By the way, since we need read in files with several columns of data and allow user to select a column, we want to use JTable. Is that reasonable?
    Thanks a lot for any suggestions!
    Jack

    Hi, there:
    Will using JTable add much overhead? I may have to use several JTables and switch among them. I can add scroll bar to or edit JTables, right?
    BTW, do you have experience about gnuplot? Can I find the command tree of gnuplot somewhere? Or do you know a better place to post question about gnuplot? unix/linux group, maybe.
    Thanks,
    Jack
    P.S. Would you guys answer my question after I use up my duke dollars? :- )

Maybe you are looking for