Launch Java app through a bat file

Hi,
Because I have to launch my Java App through a batch file, I don't know if I can create a new java class to execute this bat file to launch my Java App? Is that gonna work?
Henry.

Yes I created a batch file and tested. If I execute my batch file, the java app will be lauched as expected.
Here is my java class that execute my batch file
import java.io.*;
public class LaunchTest {
public static void main(String args[])
String cmd[] = new String[3];
try
String osName = System.getProperty("os.name" );
//System will detect current operating system
if( osName.equals( "Windows NT" ) || osName.equals( "Windows 2000" ) )
cmd[0] = "cmd.exe" ;
cmd[1] = "/C";
cmd[2] = "c:\\Run.bat"; //Run.bat will set classpath and launch my java app
else if( osName.equals( "Windows 95" ) || osName.equals( "Windows 98" ) )
cmd[0] = "command.exe" ;
cmd[1] = "/C";
cmd[2] = "c:\\Run.bat";//Run.bat will set classpath and launch my java app
Runtime rt = Runtime.getRuntime();
//running the commands
Process proc = rt.exec(cmd);
// any error message?
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
// kick them off
errorGobbler.start();
               // any error???
int exitVal = proc.waitFor();
catch (Throwable t)
t.printStackTrace();
System.out.println("error...");
And here is my batch file
@echo off
set path=e:\jbuilder4\jdk1.3\bin
set classpath=E:\JBuilder4\jdom-b7\jdom-b7\build\jdom.jar;E:\JBuilder4\jdom-b7\jdom-b7\lib\xerces.jar;.
d:
cd AutoTest\classes
java FirmwareTestPack.FirmwareMainClass
exit
When I run the java class above, Dos prompt popped up for a second then disappeared. It did not launch my Firmware pplication.
Thank you.

Similar Messages

  • How to call a java class in a bat file

    Hi
    I need to call a Test.java class in a bat files .It refer .DOM.jar
    in C:/url; How do i call the java class i need the syntax
    Thanks lot

    assuming lanch.bat, Test.class and DOM.jar are in c:\url
    assuming %JAVA_HOME% is defined (else substitue it with your java installation directory)
    here is the content of launch.bat:
    cd C:/url (or cd c:\url ) (or cd c: followed by cd url)
    %JAVA_HOME%\bin java -classpath .;DOM.jar Test
    hop that'd help,
    marvinrouge

  • Can only launch sqlDev 3.0 via .bat file

    I just downloaded 3.0 and extracted to a new folder. (winXP) The older version worked fine. Whenever I launch sqldeveloper.exe, I get " UNable to create an instance of the Java Virtual Machine"
    However, I am able to successfully launch when executing the sqldeveloper.bat file. AM I missing a configuration step?

    Make sure you're pointing to a 1.6 JDK in \sqldeveloper\bin\sqldeveloper.conf or delete the entry to get prompted to browse for it on next startup:
    SetJavaHome C:\Archivos de programa\Java\jdk1.6.0_16Hope that helps,
    K.

  • Pass return code from Java application to a .bat file.

    I have a .bat file which will execute a Java application. I want to pass the return code from the java application to the ".bat" file.
    Could you please let me know, how can I accomplish this.

    I tried that, but it doesn't return the value...
    In my Java app, I had System.exit(returnCode) and in the '.bat' file
    I have
    @echo off
    java <myApp>
    set returnCd=%?%
    echo %returnCd
    and it didn't return any value. What should I specify in set returnCd=%?% instead of ?

  • Is it possible to launch native app through third party app.

    I am making the app in which I want to launch the others app,I am able to launch the third party app but not the mobile native app. Is it possible to launch native app through third party app.
    Thanks in advance.
    Solved!
    Go to Solution.

    For example I want to launch sudoku game which is preinstalled in the phone from my application,but I am not able to do that.

  • Runing a report through a BAT file

    Hi,
    I'd like to call Report Runtime through a BAT file, indicating the RDF file I want to open and the user-password-host names for the database (so that when the file is executed the report opens without asking to log on).
    Does anybody know how to do this?
    Thanks--

    Hi
    You can call report by creating short cut for the desired Report runtime, but which is hard coded where in you have to create the short cut for the REP you desired to run. when user double clicks that icons its opens Connect dialogue box.
    Other procedure is a bit long, you create a form where in you provide the File-Open dialogue box, so that user can select the desired report, from there you can call the report from Reports
    I don't known how are this will meet your requirements
    Regrads
    Karan
    null
    ---i saw this post
    You can call report by creating short cut for the desired Report runtime, but which is hard coded where in you have to create the short cut for the REP you desired to run. when user double clicks that icons its opens Connect dialogue box.
    and i want to know how iis it done?

  • ATSServer locks up on launching java apps/flash content

    Suddenly, every time I try to launch an app that's java-based, or one that uses flash (such as the Shorter Oxford English Dictionary), or any of my browsers load a webpage with flash content, I get the following console hangup:
    com.apple.ATSServer[670] ATSServer got a fatal error (status: -4) while processing a message (id: 22) from pid=nnnn.
    com.apple.launchd[139] (com.apple.ATSServer) Throttling respawn: Will start in 10 seconds
    I have done the following that might have been proximate causes:
    cleared duplicate fonts
    removed dodgy fonts
    cleared font cache
    uninstalled MS Office 2008
    deleted fonts that the MS Office uninstaller helpfully doesn't delete
    but the problem persists. This all seemed to start after either the latest java update, or the latest MS Office 2008 update, but may be nothing to do with either. At least I can access my online banking if I use FlashBlock in firefox, but since this doesn't seem to be a font issue, can someone suggest where to go next with this?
    - padmavyuha

    Well, actually it's still not working properly, although I've got my dictionary working again - I'm getting a couple of console errors persecond while it's running - and if flash is enable in browsers, it still drops the bomb occasionally. I'll follow this up with Adobe, since it's clearly a flash issue.

  • Its not a really java question (its a bat file question)

    hi all,
    I created one bat file like below
    start java.exe -mx50m -classpath ".\SerialConnection.jar" spc.SerialConnection.SECSConnection
    its working
    but I would like to want if I open the bat file I want to disappear the dos window..
    if anyone knows please send the solution
    thanks

    Does :
    java -mx50m -classpath ".\SerialConnection.jar"
    spc.SerialConnection.SECSConnection &
    work ?No because that's Unix shell syntax which does not work in Windows.
    Jesper

  • Calling Java App through Oracle 9i Database

    Hi there,
    I have a Java application that is being invoked through an AFTER INSERT trigger on a table. The trigger calls an Oracle plsql wrapper stored procedure which fires the Java application and passes a parameter value.
    Problem: Java application should be invoked only once the commit after the INSERT statement is issued. I am unable to do this by this by using an INSERT trigger as the commit; takes place after the Java app is called?
    I know and understand that ON COMMIT TRIGGER IS NOT POSSIBLE IN ORACLE.
    Is there any other possible way to solve this problem?
    Cheers.
    Rohan
    Edited by: rbha4 on Oct 11, 2009 8:56 PM

    Unless the behaviour of DBMS_SCHEDULER has changed recently, it does a commit as part of the create_job call (or whatever subprogram you use) so is not suitable as a replacement for DBMS_JOB when submitting a job as part of a transaction.
    So, what you say is a good approach but using DBMS_JOB.
    SQL> create table t1
      2  (col1 number);
    Table created.
    Elapsed: 00:00:00.02
    SQL> insert into t1 values (1);
    1 row created.
    Elapsed: 00:00:00.00
    SQL> select * from v$transaction;
    ADDR                 XIDUSN    XIDSLOT     XIDSQN     UBAFIL     UBABLK     UBASQN     UBAREC STATUS
    START_TIME           START_SCNB START_SCNW START_UEXT START_UBAFIL START_UBABLK START_UBASQN START_UBAREC
    SES_ADDR               FLAG SPA REC NOU PTX
    NAME
    PRV_XIDUSN PRV_XIDSLT PRV_XIDSQN PTX_XIDUSN PTX_XIDSLT PTX_XIDSQN     DSCN-B     DSCN-W  USED_UBLK  USE
        PHY_IO     CR_GET  CR_CHANGE START_DAT  DSCN_BASE  DSCN_WRAP  START_SCN DEPENDENT_SCN XID
    PRV_XID          PTX_XID
    000000035DB85B80         10          0    2781184          3       1450       4705         18 ACTIVE
    10/12/09 09:30:21    2567038319          9          2            3         1450         4705           18
    0000000344DFA6D0       3587 NO  NO  NO  NO
             0          0          0          0          0          0          0          0          1          1  
             0         39          0 12-OCT-09          0          0 4.1222E+10             0 0A00000000702A00
    0000000000000000 0000000000000000
    1 row selected.
    Elapsed: 00:00:00.02
    SQL> begin
      2  dbms_scheduler.create_job
      3  (job_name=> 'Adhoc1',job_type=>'PLSQL_BLOCK',
      4  job_action=>'begin null; end;');
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01
    SQL> select * from v$transaction;
    no rows selected
    Elapsed: 00:00:00.01
    SQL> Edited by: dombrooks on Oct 12, 2009 9:35 AM

  • How to start java app with many jar files

    Hi,
    I have an application that makes use of 50 jar files. When I try to start the application, I need a very long command line like
    java -classpath file1.jar;file2.jar;file3.jar; ... de.me.myapp.myclass
    This is not very handy. Is there a shorter way if all jars are in the same directory? I would like a command like this:
    java -cp /usr/local/my_jars de.me.myapp.myclass
    but this does not work.
    Any Idea if there is an easy solution?
    Andreas

    aaa801 wrote:
    i think there was a way to do it but it eather only worked with javac or java exe which is a lil problem but i did -cp .;./*.jar or something of that sortAs of Java 6, the classpath can contain wildcards.
    http://java.sun.com/javase/6/docs/technotes/tools/solaris/classpath.html

  • Unable to deploy and run WD Java app through NWDS with a remote J2ee engine

    Hi ,
    We have a clustered server instance configuration in our environment.
    I have already added the message server port and the server details in the remote J2ee engine configuration in NWDS through windows->preferences .
    I found the port no. and the host server name using <servername>:<portname>sap/monitor/systeminfo
    Also, I can see the SDM , dispatcher and the server running/shown in green in the J2ee engine setting.
    But when I was trying to connect deploy and run the application, first it asks for the SDM password and after entering it , it aborts with the following message :
    Sep 18, 2007 8:32:15 PM /userOut/deploy (com.sap.ide.eclipse.sdm.threading.DeployThreadManager) [Thread[Deploy Thread,5,main]] ERROR:
    [001]Deployment aborted
    Settings
    SDM host : XXX00
    SDM port : 50018
    URL to deploy : file:/C:/DOCUME1/check1/LOCALS~1/Temp/temp11565my_pro.ear
    Deployment exception : Server XXX00 did not accept login request as admin on port 50018. Details: ERROR: Could not establish connection to server XXX00 at port 50018: Connection timed out: connect
    Inner exception was :
    Server XXX00 did not accept login request as admin on port 50018. Details: ERROR: Could not establish connection to server XXX00 at port 50018: Connection timed out: connect
    Can anyone let me know what can be the reason.
    Best Regards
    Sid

    Hi Siddharth,
    Re-start  SDM process of J2EE engine.Make sure when you are deploying u r project others are not deploying their project.
    SAP Note : <a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bc_jas/~form/handler">701654</a>
    Regards,
    Mithu

  • Launch Java App from Windows Desktop

    What's the best way to launch a Java application from a Windows XP desktop without the console showing?

    If your class Main.class is part of a package, you cannot invoke Main directly without providing the package. You may have to include the -classpath option (depending of the working directory). The default value for -classpath is "."
    You should try:
    javaw myPackage.Main
    (if the working directory is parent to directory 'myPackage')
    or
    javaw -classpath .;c:\xxx\xxx\. myPackage.Main
    "c:\xxx\xxx\" is your root package's parent directory. Note that you may have to double quote the specified path.
    For details:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html

  • Executing a java app through AIR

    Ok, I have command, which when I execute in a CMD, it runs fine:
    "jre/bin/java" -DSTOP.PORT=8887 -DSTOP.KEY=worx -Xms256M  -Xmx512M -jar lib/start.jar
    any ideas on how to execute this in AIR ?
    thank you,
    Giorgoc

    Try giving absolute path for the jre. for e.g.  C:/Program Files/Java/jre

  • Launch Java app without going to shell window?

    I saw lots of applications that were build with Java but run just like a Windows applications.
    Can you give me any clues on how to do this? For example, what can I do if I wish to launch a Java application without having to open the command-line window?

    yes, javaw meets what i needed @_@

  • Executing java apps without individual JAR file entries in CP???

    Hi all,
    I'm used to having to specific EACH separate jar file in the CLASSPATH when executing a java application. See the batch file example below.
    Is there a way to not have to spell out EACH JAR file separately in this fashion? Eg just refer to the JAR directory?
    What do people usually do here when delivering a java application to someone else, given the application has your own class files in a JAR, plus other 3rd party class files? Do you always have to build up a long JAVA batch file like the one below to enable the application to be run?
    -----------example-------
    c:\Progra~1\jdk1.3.1\bin\java -classpath .;deploy\mail.jar;deploy\activation.jar;deploy\xerces.jar;deploy\commons-digester.jar;deploy\commons-collections.jar;deploy\commons-beanutils.jar sns
    Cheers
    Greg

    A simple way is to have a class inside your program load all the JAR files needed.
    That way, when the main class file starts, place a call to the class that will load
    the classes for you. Like this one below...
    import java.lang.*;
    public class MyJarLoader {
    public MyJarLoader() {
    System.load(String); // replace 'String' with the file pathname of a JAR file.
    // you will need to do this for each JAR file, just add another call to System.load() here

Maybe you are looking for