How to call up an executable file (eg. MSPaint) from within my java program

How to call up an executable file (eg. MSPaint) from within my java program

Ummm... why would you want to get MSPaint anyway? Even in the absense of real software, Java's own graphics tools are way more sophisticated - with a little time and effort, you could write a simple paint package that beat MSPaint hands down.

Similar Messages

  • How can native executable files be started from within a Java application.

    Hi Everyone,
    I am currently working on an application that will have the ability to start a program within Windows. What I intend on having is a button within my GUI that can start Microsoft Word. I am completely lost as to where I should begin in order to make this work. If anybody has any pointers they will be greatly appreciated. Thanks.
    Regards
    D

    Hi ,
    easy:
    Runtime.getRuntime().exec(new String[]{path,name});
    see:
    http://java.sun.com/j2se/1.3/docs/api/java/lang/Runtime.html
    HTH

  • Executing a Java Program from within a Java Program

    I need to execute the following Java Program from withing another Java Program. The office toolbar command line is
    D:\WINDOWS\system32\java.exe -cp E:\Development\Eclipse\UpdateServer\Classes -server -showversion UpdateServer
    I can find no combination of ProcessBuilder commands, including those that include "Cmd.exe /c" that will make this program run from within another Java Program. All the examples I can find only show how to run Windows *.exe programs. I keep getting error 123 from ProcessBuilder.start(), but I can find no documentation for error 123.

    Assuming your code didn't get mangled by the forum
    (it's missing one "), it may be that your "-cp
    E:\\Develop.." argument is getting quoted as it has a
    space in it; try passing "-cp" and "E:\\Develop..."
    as two arguments.That worked; specifically the following tested OK:
    ProcessBuilder pb = new ProcessBuilder("D:\\WINDOWS\\System32\\Java.exe", "-cp", "E:\\Development\\Eclipse\\UpdateServer\\Classes\\", "-server", "-showversion", "UpdateServer" );
    pb.directory(new File("E:\\Development\\Eclipse\\UpdateServer\\Classes\\"));
    try{
         Process p = pb.start();
         InputStream is = p.getErrorStream();
         InputStreamReader isr = new InputStreamReader(is);
         BufferedReader br = new BufferedReader(isr);
         String line;
         while ((line = br.readLine()) != null)
              System.out.println(line);
         p.waitFor();
    }catch(IOException ioe){
    I was sure I tried that exact same code before, and it did not work, but now it does, at least at the top level (when it is in main of a test program). I will have to wait to try it until later when it is buried deep in a subroutine.

  • How to use .dbf files zipped into a .zip file from within a java program

    i have a .zip file containing several .dbf files.
    the zip file is automatically downloaded regularly and data from the .dbf files is inserted into the database.
    how do i facilitate automatic extraction of a zip file or how do i fetch data from the .dbf file? (this cannot be done manually)
    anu.

    you could write a little polling class checking the zip file. you can use the java.util.jar package to extract the zip file (http://java.sun.com/docs/books/tutorial/jar/api/index.html). you could also use Jakarta ant (http://ant.apache.org/manual/index.html) to do this job (core task "zip") and call ant's target file on a regular basis (dependend on the OS you use, you can set os tasks/schedules).

  • Running executable jar from within a java program

    Is there a way to launch an executable jar in a java program? I tried wrapping the jar in an exe and calling it using Runtime exec() and though this approach works it does only for windows. I want it to work for unix/linux too.

    jaki wrote:
    Yes, but it's a sub process.Nope.
    Hence the calling process doesn't quit unless the called one returns.Wrong.
    My calling program is actually a jar and what Im trying to do is delete the jar after it's done running. But the above method (of launching a separate jar doing the deletion) doesn't seem to work for the above mentioned reason.Wrong.
    If you could tell me any other way it would really be a big help.You don't need any other way. Maybe you need to allow some time for the calling program to wind up. 20 seconds may be overkill, but I'm not in the mood to find how short it can be and still succeed.
    The two classes are packaged in separate jars.import java.io.IOException;
    public class Deletee {
        public static void main(String[] args) {
          try {
             String[] cmds = {"java", "-jar", "E:/temp/Deleter.jar"};
             Runtime.getRuntime().exec(cmds);
             System.exit(0);
          } catch (IOException ex) {
             ex.printStackTrace();
    import java.io.File;
    import javax.swing.JOptionPane;
    public class Deleter {
       public static void main(String[] args) {
          File file = new File("E:/temp/Deletee.jar");
          try {
             Thread.sleep(20000);
          } catch (InterruptedException ex) {
             ex.printStackTrace();
          if (file.delete()) {
             JOptionPane.showMessageDialog(null, "Deleted");
          } else {
             JOptionPane.showMessageDialog(null, "Oops");
    }Try it and see for yourself.
    db

  • Permission denied when I execute a unix command from within my java applet.

    Hi Gang,
    Forgive me if this is not the appropriate forum for this problem. I'm posting this problem on this forum since I got no answers on the other forum I posted on.
    I've written a simple java applet that runs a unix command and then displays some information. The applet compiles fine, and runs perfectly from the command line on my unix system.
    However, when I point a browser at the applet from my desktop PC I get the following error as taken from the java console:
    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
    This is of course the first line in a long line of error messages. It appears that I am not able to execute a command on the unix system through my applet. I know the problem is with trying to execute a unix command since commenting it causes no error in the web browser. This is the command I'm using in java to execute the unix command:
    p = Runtime.getRuntime().exec("ps");
    Here's the html file on the unix system:
    <html>
    <head></head>
    <body>
    <appletcode=G.class height="250" width="400">
    Your browser does not support the applet tag.
    </applet>
    </body>
    </html>
    I won't list the java code since it is compiling and working on the command line. But, if you want to see it I'll provide it.
    I've done quite a bit of research on this and it seems that a great number of people have similar problems reading or executing files through java. I have yet to find a solution to this problem.
    Here are some details about my setup:
    Server:
    HP9000 running HP/UX 11.23
    Apache Web Server 2.0.35
    Java 1.5
    Desktop PC:
    Win2K Pro
    Internet Explorer 6
    Java 1.6
    If you have a solution I would be very grateful! This problem is keeping me from writing my application!
    thanks!
    kev

    Multi-posted.
    Already answered here http://forum.java.sun.com/thread.jspa?threadID=5225314&messageID=9916327#9916327

  • How to start a browser from within a java program?

    I want to make a help file for my java program and want to run the browser from the menu of my program.
    How can I start my browser from my program?
    A small code will be helpful.
    Thanks.
    Niteen

    This should work on Windows without having to know where the browser is located. See http://www.javaworld.com/javaworld/javatips/jw-javatip66.html for more details
      public static void viewHtml(URL url, boolean fixHtmlExtension){
          String cmd = "rundll32 url.dll,FileProtocolHandler " + url.toExternalForm();
          if (fixHtmlExtension){
            //There is a bug in rundll32. For http requests, it doesn't like .html or .htm extensions,
            //but replacing the 'm' with '%6D' works. 
            //This fix is not needed for file requests.
            if (cmd.endsWith(".htm")){
              cmd = cmd.substring(0,cmd.length()-1) + "%6D";
            else if (cmd.endsWith(".html")){
              cmd = cmd.substring(0,cmd.length()-2) + "%6Dl";
          Process process = Runtime.getRuntime().exec(cmd);
          try{
            process.waitFor();
          catch(InterruptedException e){

  • Problem with creation of a jar file from inside a java program

    Hi,
    I am trying to create a jar file at runtime from within a java program.
    I am able to create a jar file just fine using:
    String[] jarArgs = new String[3];
    jarArgs[0] = "cvf";
    jarArgs[1] = "C:\temp\myjar.jar";
    jarArgs[2] = "C:\temp\this";
    sun.tools.jar.Main main1 = new sun.tools.jar.Main(System.out, System.err, "jar");
    main1.run(jarArgs);However, when I look at the jar it puts the absolute path to the files inside such as:
    C:\temp\this\is\my\package\Class.class
    instead of only this\is\my\package\Class.class
    When running the jar command from the command line it works just fine and I have the relative paths in my jar file.
    Does anyone have any experience with this and could help me out?
    Thanks in advance
    Edited by: mruf on Apr 11, 2008 1:51 AM

    Shouldn't jarArgs[2] = "-C C:\temp\this"

  • Call third party Executable file.

    How to call third party executable file from SAP as a modal.
    I have a drum filling system. I want to call executable file of drum system which take a weight from instrument and write a text file. After completion of this SAP will read that text file and write it to screen.

    the best way to do it is using RFC (remote function call)
    your drum tool should be compatible in order to do it
    if not you can still send a command to operating system in order to execute your tool but this is a second choice

  • How to execute a packaged function from within DML

    Hi
    can someone explain in how many ways can we execute a packaged function from within a DML statement.
    examples will help.
    Thanks

    Hi,
    There's no difference between using functions in DML and using functions in any other SQL statement. Almost any place where a literal is allowed, you can have any kind of expression, including a an expression involving one or more functions.
    For example, in
    UPDATE  table_x
    SET     column_a = 0
    WHERE   column_b > SYSDATE;You could use functions instead of 0, column_b, or SYSDATE. (Actually, SYSDATE is a function.) You can not use functions instead of table_x or column_a (since it is to the left of the "=" sign).

  • How to execute a Perl program from within a Java prog

    How do I execute a Perl program from within a Java program.
    Lets say the Perl program that I want to execute is 'abc'. Now, 'abc' requires some input that I want to give it from within the Java program. How do I do it?
    And finally, how do I execute that Perl program from within the Java program.
    If I execute the Perl program alone then I do it in the following way -
    perl abc inp1 inp2 inp3
    where inp1, inp2, inp3 are inputs to the Perl program. I will not be able to change or modify the coding of the Perl program - 'abc' as I do not have access to its code. Its a kind of an application whose usual method of execution is in the above shown way. So, how do I execute 'abc' from within a Java program.

    what part of don't crosspost, don't you understand?
    http://forum.java.sun.com/thread.jsp?forum=4&thread=427193

  • How to run java programs from a master java program?

    Hello,
    I have several java programs which run from the command prompt. I am seeking help with code for starting java programs from within a java program. For example, a program called master.java works something like this:
    import java.*;
    create connection pool
    create variables and result sets
    start/run slave1.java (var1, var2);
    start/run slave2.java (var3, var4, var5);
    start/run slave3.java (var1, var4);
    end of program master.java
    Each of the slave.java programs will run for up to an hour. I do not want the master.java program to pause for each slave program to stop. Instead, the master program will keep running and multiple slave programs will be running simultaneously with the master program. When a slave program starts, it is on its own. Also, if possible, I would like to have each of these slave.java programs open in a new separate command window, so I can observe each slave program running in separate windows.
    Any suggestions for code or helpful documentation are greatly appreciated.
    Thank you,
    Logan

    Thank you all.
    At the bottom of master.java I have successfully started a batch file with these lines:
    String jcmd = "cmd.exe /c start c:/data/simulations/MsgViewCount2.bat";
    Process proc = Runtime.getRuntime().exec(jcmd);
    But I still cannot get a java program to start. Here is one variation I have tried:
    String [] cmdArray = new String[2];
    cmdArray[0] = "java";
    cmdArray[1] = "slave1";
    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec(cmdArray);
    This compiles, and no errors occur, but nothing happens.
    Regarding this comment:
    Why Runtime.exec? Either make the slaves Runnable or
    just call their main() methods.
    Oh, I see. Sepearate output. :PNone of the slave.java programs have any output.
    Thanks again.

  • Executing C program from with a java program

    How do you call a c program from within a java program, and parse arguments into that program and return something.
    Cheers for any reply...

    Read http://www.javaworld.com/jw-12-2000/jw-1229-traps.html

  • Executing a Perl program from within a Java prog

    How do I execute a Perl program from within a Java program.
    Lets say that the Perl program that I want to execute is 'abc'.'abc' requires some input that I want to give from within the java program. How do I do that? Then I want to execute the Perl program from within the Java prog. How do I do it?

    don't crosspost.
    http://forum.java.sun.com/thread.jsp?forum=31&thread=427211&tstart=0&trange=100

  • How to get the current executing file/itself absolute directory?

    hellooo,
              gentlemen/lady, how to get the current executing file/itself absolute directory?
              thanks
              

              Hello,
              you can get the real path information of the JSP through the servlet context:
              http://java.sun.com/products/servlet/2.2/javadoc/index.html
              javax.servlet
              Interface ServletContext
              Method getRealPath
              Christian Plenagl
              Developer Relations Engineer
              BEA Support
              [email protected] (alex mok) wrote:
              >hellooo,
              >
              >gentlemen/lady, how to get the current executing file/itself absolute
              >directory?
              >
              >thanks
              

Maybe you are looking for

  • Leopard SSH problems

    I get a lag when I try to SSH to our server. I've been searching around and there were a bunch of SSH/DNS problems early in Leopard's lifetime. How have they not fixed this? I'm running 10.5.8. I found this thread on this forum. This is the response

  • Page numbering - multiple repeating frames

    Hi, It's a bit tricky in explaining this but I shall try to do my best. This is an invoice report with 2 parts (everything in the main section), main invoice and summary. The main invoice is in repeating frame R2 and summary (matrix report) is in rep

  • Why doesn't my Dynamic link work and or why am I getting these error msgs?

    Im using CS6 of Encore while using Pr CC 2014.....I dont have access to the Dynamic link option either....Can I get some assistance with my issue...?

  • Oracle Parallel Server

    This is a question about availability of Oracle Parallel Server on linux. I tried to ask OTN but their answer was really strange : they adviced me to go to discussion board! I suppose that Parallel was not realized for linux oficially yet but this is

  • Jumping to the top of the page like on iPhone

    You don't realize how much you need or like a feature until you have it and then it's gone. I love on the iPhone that you can tap the top of the screen to jump straight to the top of the page. This of course works in Contacts, Emails and nearly every