Solved

Execute .bat file from applet?

Posted on 1997-04-04
1
549 Views
Last Modified: 2012-06-21
Please,

Can I execute a .bat file from Java applet?

I am trying execute a .bat file by using exec(String) method.

My code is:

param.bat
---------
c:\dos\tree.com

myFile.java
------------
        Process proceso;
        try
        {
            System.out.println("Runtime:"+Runtime.getRuntime());
                   
proceso=Runtime.getRuntime().exec("c:\\sistel\\ejemjava\\pt\\param.bat");

            System.out.println("proceso:"+proceso);
        }
        catch(IOException e)
        {
            System.out.println("bad shell");
        }

        System.out.println("The end");
    }


It do not execute the command system 'tree', but it print "The end".

It is right if I do not use a bat file, like this:

proceso=Runtime.getRuntime().exec("c:\\dos\\tree.com");

Thank you,

Arancha

0
Comment
Question by:apico
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
JWBito earned 50 total points
ID: 1219418
Try
Runtime.getRuntime.exec("command.com /c c:\\sistel\\ejemjava\pt\param.bat");

On NT, command.com would be cmd.exe, instead.  

I would like to know how to get at system environment variables from java.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unhandled exception type Exception 18 65
null output 3 59
Chrome and Firefox Java 5 89
How to log java errors in tomcat 8 39
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question