Runtime.exec() on Linux RedHat. help!!

Guys
I've having a lot of problems with Runtime.exec() across RedHat platforms.
I'm trying to execute a external process but it doesn't responds.
when I execute the 'ps' sentence the process appears, but apparently don't work.
If I run this proccess at the command line, it works fine.
Can anyone offer an help?
Thanks

Don't forget that the output of the "Process" is not redirected to "System.out".
--> if you want to see the output, you'll have to get the output stream of the process and dump it yourself
InputStream processOutput = process.getOutputStream() ;
byte buffer[] = new byte[ 512 ] ;
while( true ) {
int read = processOutput.read( buffer ) ;
if( read<=0 ) {
break ;
System.out.write( buffer, 0, read ) ;
}

Similar Messages

  • How to make Runtime.exec call Linux exec?

    Howdy,
    I am trying to use a combination of 'find' and 'rm' to delete all files with a certain extension in a directory and all of its subdirs.
    Here's the command:
    Process proc = runtime.exec("find " + dir + " -name '*.vcs' -exec rm -rf {} \\;");
    It's failing, not sure why, the exitCode is 1 instead of 0. I'm not sure if it's because I have to escape the '\' character, or if it's because I am calling Linux's 'exec' function within a Java exec() call, or something else entirely.
    The easiest thing to do would be to just use rm, but that doesn't seem to be an option. With rm it seems to be all or nothing -- If I try:
    rm -rf *.vcs
    it fails if it doesn't find a file with that extension in the start directory (even though I've specified -r). But if I enter:
    rm -rf *
    it nukes my directories AND files, something I don't want to happen. I realize this is a Linux thing, I'm just explaining it here as background, just in case.
    Anyway, so is there a way to do this? Perhaps with another system call, without using Linux's exec()?
    Many thanks
    Bob

    import java.io.*;
    public class ExecutingALinuxCommand
        static class PipeInputStreamToOutputStream implements Runnable
            PipeInputStreamToOutputStream(InputStream is, OutputStream os)
                is_ = is;
                os_ = os;
            public void run()
                try
                    byte[] buffer = new byte[1024];
                    for(int count = 0; (count = is_.read(buffer)) >= 0;)
                        os_.write(buffer, 0, count);
                catch (IOException e)
                    e.printStackTrace();
            private final InputStream is_;
            private final OutputStream os_;
        public static void main(String[] args)
            try
                String dir = System.getProperty("user.home") + "/work/dev";
                String[] command = {"sh","-c", "find " + dir + " -name '*.java' -exec grep -l Runtime {} \\;"};
                final Process process = Runtime.getRuntime().exec(command);
                new Thread(new PipeInputStreamToOutputStream(process.getInputStream(), System.out)).start();
                new Thread(new PipeInputStreamToOutputStream(process.getErrorStream(), System.err)).start();
                int returnCode = process.waitFor();
                System.out.println("Return code = " + returnCode);
            catch (Exception e)
                e.printStackTrace();
    }

  • Runtime.exec() under Linux

    My game's installer works on windows and mac but on linux it's getting this error:
    java.io.IOException: Cannot run program "javaw": java.io.IOException: error=2, No such file or directory
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    Here's my code:
      public void runProgram(){
        String dir = folder;
        if(os_type == LINUX && dir.charAt(0) != '/'){
          dir = "/"+dir;
        File file = new File(dir+"SFC_Updater.jar");
        if(file.isFile() == false){
          System.err.println("Could not find updater jar: "+file.getPath());
          throw new RuntimeException();
        if(os_type == LINUX){
          System.err.println("Attempting to run with special linux arguments because linux is SPECIAL!");
          String[] args = new String[4];
          args[0] = "javaw";
          args[1] = "-jar";
          args[2] = "\""+dir+"SFC_Updater.jar\"";
          args[3] = dir;
          try{
          Runtime.getRuntime().exec(args);
          catch(Exception e){
           System.err.println("Linux Fails.");
           e.printStackTrace();
        else{
          try{
            Runtime.getRuntime().exec("javaw -jar \""+dir+"SFC_Updater.jar\" "+dir);
          catch(Exception e){
            e.printStackTrace();
      }Thanks

    Have you tried including the full path for javaw in
    the Linux version?It is interesting to note that the Linux version does not have a javaw

  • Runtime.exec on Linux

    Hi,
    I'm having some difficulty getting Runtime.exe() to work on Linux. I was trying to run "make oldconfig" from my Java program.
    public Action()
       Process p = Runtime.getRuntime().exec ( "make oldconfig" );
       InputStream processStream = p.getInputStream();
       OutputStream commandStream = p.getOutputStream();
       InputStream procErrorStream = [/getErrorStream();
       p.waitFor ();
    private void outputData ()
       int hasInput;
       if  ( ( hasInput = processStream.available() ) >0 )
          byte[] buffer = new byte [hasInput];
          int len = processStream.read(buffer);
          if ( len > 0 )
             System.out.println( new String ( buffer, 0, len ) );
       if  ( ( hasInput = procErrorStream.available() ) >0 )
          byte[] buffer = new byte [hasInput];
          int len = procErrorStream.read(buffer);
          if ( len > 0 )
             System.out.println( new String ( buffer, 0, len ) );
    }I don't see any errors from this command, but it doesn't look like the "make oldconfig" is called because I'm not seeing any outputs. Can anyone help or give me some hints to debug this? Thanks.

    The line
    InputStream procErrorStream = [/getErrorStream();
    looks a bit dodgy to me

  • Runtime exec undel linux

    Hi
    I am trying run this peace of code under linux System
    String c="/usr/java/jdk1.6.0_02/bin/java -jar \"/root/JavaApplication1/dist/JavaApplication1.jar\"  \"a\"  \"b\"  \"c\"" ;
           try {
           Process p=Runtime.getRuntime().exec(c);
          } catch (IOException ex) {
               ex.printStackTrace();
           }JavaApplication1.jar should display a frame
    but I do not have any thing
    and the exit code of the process is 0
    how can I fix this
    any help
    regards

    Have you tried including the full path for javaw in
    the Linux version?It is interesting to note that the Linux version does not have a javaw

  • Can't redirect the Runtime exec output

    I'm trying to get mysqldump to give me some output which I can redirect to the tmp1 location
                   String tmp2 = "mysqldump";
                   Runtime rt1 = Runtime.getRuntime();
                   if(File.separatorChar == '\\') {
                        tmp2 = "\"C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\mysqldump\"";
                   tmp1 = tmp2 + " > " + tmp1;
                   rt1.exec(tmp1);All I want to see at this point is just the error message telling me how to use mysqldump.
    After that I'll do something useful.
    I'm running under NetBeans and if I don't try to redirect I get nothing in the output window.
    Of course, if I run it from a Command box, I see the expected output.
    I know I'm running the program because if I change it to the nonsense mysqldump3, it will tell me that it can't find the file.
    I can't figure out where the output is going and how to capture it.
    Any ideas would be appreciated.
    Ilan

    Ilan wrote:
    Hi Sabre,
    Since I didn't understand your code, I'll use it as a chance to learn something.
    I don't understand what cmd.exe is doing. It is just opening a DOS box?No! It is interpreting the command string.
    Why do you need that? (Maybe I do and I don't know so....)You need to learn a good bit more about your operating system. Get a good book on Windows.
    >
    The simplest thing would be String command = "mysqldump > file.sql".
    Why shouldn't that work?1) Because the directory containing your mysqldump is not in the PATH.
    2) Because the redirection operator '>' is only applicable when interpreted by the command processor (cmd.exe). Reads your Windows manual.
    >
    The reason I need the explicit path is because mysqldump isn't on my Windows path (Linux is nicer that it is in usr/bin, so there is no problem.)
    So I detect Windows and for Windows put the path and command in quotes.
    (Now that I think about it, cmd.exe probably wouldn't work in Linux anyway.)On Linux you will need your shell to interpret the redirection operator '>' .
    >
    What is that "/C" all about? Go to drive c:?
    Your first attempt looks like a confusion with mysqldump, once without a path followed by a path.
    That one I don't understand at all.
    How do I go about getting control of the stderr, if I don't already have control?
    BTW, I haven't yet tried it in Linux. First I'll get the Windows version going.
    Thanks for your reply. I'll try to learn from it.You need to read, read again, study and then implement the recommendations in http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .
    Sorry if this sounds like I'm passing the buck but your lack of knowledge of Windows, Linux and Runtime.exec() means I cannot help without writing a large tutorial.

  • Runtime.exec() on Unix with "grep"

    Hi does someone know how to execute a Unix command which is a ps result piped to grep. What I have runs perfectly for a simple ps like ps -aux runMyCommand, but not for something like ps -aux runMyCommand | grep 8080. I am using Runtime.exec() method.
    Please help.
    Thanks,

    the pipe is handled by the shell, so you cannot just do a runtime.exec("ps aux | grep 8080"), you could try something like this;
    String cmd = "sh -c 'ps aux | grep 8080' ";
    Runtime.exec(cmd);
    or even
    String cmd = "sh -c 'ps aux | grep 8080 | grep -v grep'";

  • Runtime.exec() on RedHat Linux

    Guys
    Like many before me, it seems, I've having a nightmare with Runtime.exec() across platforms when executing local files.
    I've gone for the basic but robust strategy of writing the required function to a local file and then executing the file. This has worked fine on Windows NT/2000 and on Solaris. But RedHat Linux doesn't want to know.
    I know my permissions are good to execute. I can create the file then run it at the command line, but then whenever I go to run from within Java I get an exit value of 255.
    An old chestnut, I know. But can anyone offer an help?
    Cheers
    Dom

    Here's a small class & main method that illustrates the problem.
    The output I get is:
    File path: /tmp/Temp26345.sh
    chmod +x exit value: 0
    Executing file: 255
    I can then go into /tmp and run ./Temp26345.sh at the command line and get the "ls" command to run.
    import java.io.*;
    public class FileExecutor
         public static void main( String[] args )
              if( args.length == 0 )
                   System.out.println("Arguments must be given: [filename] [writeable]");
                   return;
              try
                   FileExecutor fe = new FileExecutor();
                   File executable = fe.createFile( args[0] , args[1] );
                   fe.executeFile( executable );
              catch( Throwable t )
                   t.printStackTrace();
         public File createFile( String fileName , String contents )
              throws IOException
              //Create the file.
              File tempFile = File.createTempFile( fileName , ".sh" );
              //Write to the file.
              FileOutputStream fos = new FileOutputStream( tempFile );
              OutputStreamWriter osw = new OutputStreamWriter( fos, "UTF-8" );
              int length = contents.length();
              osw.write( contents , 0 , length );
              osw.flush();
              osw.close();
              fos.close();
              return tempFile;
         public void executeFile( File file )
              throws InterruptedException , IOException
              String filePath = file.getAbsolutePath();
              System.out.println( "File path: " + filePath );
              Runtime runtime = Runtime.getRuntime();
              //Actual system permission.     
              Process process_perm = runtime.exec( "chmod +x " + filePath );
              int exitValue = process_perm.waitFor();
              System.out.println( "chmod +x exit value: " + exitValue );
              //Execute the file.
              Process process_exec = runtime.exec( filePath );
              exitValue = process_exec.waitFor();
              System.out.println( "Executing file: " + exitValue );

  • Runtime.exec() does not work under Linux

    Hi,
    I have a generic application runner class that runs an external
    program and redirects stdout/stderr to a buffer/file.
    While everythings works just fine under Windows, I get the
    following exception under Linux trying to run the Java interpreter
    'java':
    java.io.IOException: "/usr/lib/SunJava2-1.3.1/jre/bin/java": not found
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:139)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:546)
    at java.lang.Runtime.exec(Runtime.java:413)
    I have checked that the file /usr/lib/SunJava2-1.3.1/jre/bin/java
    exists.
    Any help appreciated!
    Marc

    can I ask how you solved it? I am having a problem
    with quotes just now to and it might help me!I simply tested what the current platform is and
    only used quotes under Windows.
    Marc

  • Problem of executing a process under Linux using Runtime.exec

    Hi, All
    I am having a problem of executing a process under Linux and looking for help.
    I have a simple C program, which just opens a listening port, accept connection request and receive data. What I did is:
    1. I create a script to start this C program
    2. I write a simple java application using Runtime.exec to execute this script
    I can see this C program is started, and it is doing what it supposed to do, opening a listening port, accepting connection request from client and receiving data from client. But if I stop the Java application, then this C program will die when any incoming data or connection request happens. There is nothing wrong with the C program and the script, because if I manually execute this script, everying works fine.
    I am using jre1.4.2_07 and running under Linux fedora 3.0.
    Then I tried similar thing under Windows XP with service pack2, evrything works OK, the C program doesn't die at all.

    Mind reading is not an exact science but I bet that you are not processing either the process stdout or the stderr stream properly. Have you read http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html ?

  • Problems with Runtime.exec inside OC4J in OAS!!! help!!

    Hi all,
    I have a method on my webapplication and the same call a script .cmd on windows and a .sh on unix using Runtime.exec command, inside this script have a call to a java program ie.
    java JMSAdmin < jcajms.txt
    OK, this is fine in OC4J Standalone 10.1.3 in windows and linux but in OAS 10.1.3 the same not run and not throw any error. Its is a BUG ?? limitation ?? OAS ignore a call to another java ??
    please help.
    Tanks

    Normally, you must prepend the command with a call to the command shell (eg /bin/sh).
    But I suspect that this call isn't allowed due to Java EE specification restrictions.

  • Performance issue Runtime. exec("cp folder1 folder") in Linux,Weblogic.

    Using Runtime. exec() copying files from folder1 to folder2 using cp command in Linux. It will take each file copy 2 sec if we use web logic 10.3 and jrocket. if we run in Linux without web logic it takes only 0.013 sec. why it takes more time to load cp command with web logic.
    Environment
    Weblogic 10.3
    Linux 5.2
    Jrocket 1.6

    A 64 bit VM is not necessarily faster than a 32 bit one. I remember at least on suggestion that it could be slower.
    Make sure you use the -server option.
    As a guess IBM isn't necessarily a slouch when it comes to Java. It might simply be that their VM was faster. Could have used a different dom library as well.
    Could be an environment problem of course.
    Profiling the application and the machine as well might provide information.

  • How do I copy a file to a remote server using runtime exec - plz Help!

    Hi,
    I am trying to copy a file to a remote server using a runtime exec command as follows:
    Runtime.getRuntime().exec("scp "+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_PATH_JAR)+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_JAR_NAME)+".jar "+" "+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_PATH_TWO_USERNAME)+"@"+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_PATH_TWO_URL)+":"+getProperty(ListNewHandsetDetailsConstant.PROP_OUTPUT_PATH_TWO_JAR));
    Problem is this statement does not execute, as when I try it directly on command line, it requests for a password. Any suggestions on how I can get rid of that? I think I might have to configure my ssh_config file, but when I did some "Googling", I found the configuration settings of a ssh2_config file. I tried those (changing it to Host-based Authentication), but it didn't recognise them. Please help, this is so urgent!
    Regards,
    Simz

    Don't use Runtime.exec (or ProcessBuilder) for this. Check out JSch at JCraft (or some other Java SSH API.

  • Runtime.exec(), linux and redirection

    Hi all,
    I need to exec an external command from java under linux, and have both the stderr and stdout of the command redirected to the
    stdout, so that I can capture them and keep them in synch in the java app. I've tried many combination, but I'm unable to make
    this work: only the standard output shows up. Note that I can make this work under windows.
    A java code example and a small C example to simulate the program to be invoked follows. Running the java program should show both the "messsage" and the "error" lines, but it shows only the "message" ones.
    Note that removing the apparently redoundant ">&1" doesn't solve the problem. I got a suggestion to modify the exec invocation into
    String[] cmd = { "/bin/sh", "-c", "./test1 >&1 2>&1" };
      Process p = Runtime.getRuntime().exec(cmd); but that didn't work eiter.
    Can anyone tell me where I'm wrong?
    Roberto
    ======================= class test.java ================================================
    import java.io.*;
    public class test {
      public static void main(String args[]) {
        new test();
      public test() {
        try {
          Process p = Runtime.getRuntime().exec("/bin/sh -c ./test1 >&1 2>&1")
          InputStream inStr = p.getInputStream();
          BufferedReader inBr = new BufferedReader(new InputStreamReader(inStr));
          String line;
          while((line = inBr.readLine()) != null) {
            System.out.println("line = "+line);
          try {
            p.waitFor();
          } catch(InterruptedException ex) {}
          System.out.println("process terminated with code = "+p.exitValue());
          inBr.close();
        }catch(IOException ex) {
          System.out.println("IOException : "+ex.getMessage ());
    }======================= end of class test.java ================================================
    ======================= test1 program ================================================
    #include <stdio.h>
    int main(int argc, char **argv) {
      int i;
      for(i=0; i<100; i++) {
        fprintf(stdout, "message %d\n", i);
        fprintf(stderr, "error %d\n", i);
    }======================= end of test1 program ================================================

    Redirection dosen't work with Runtime.exec(), it really dosen't have sense. Do the foolowing:
    String[] cmd = { "/bin/sh", "-c", "./test1" };
    Process p = Runtime.getRuntime().exec(cmd);
    OutputStream out = p.getOutputStream();
    //now wrte out to the file, formating as you want
    What is doene obove is execute your command, without redirection, and the obtaininh the output stream of the created process. This is "the place" where the process will write everithig it'll would write in the console if executed there.
    The handle the OutputStream as any other OutputStream, and write it to the HD or do whtever you want.
    Abraham.

  • Need help with Runtime.exec()

    I need help getting my program to run a different java program through the command prompt using the runtime.exec() method. This is my code so far:
    import javax.swing.JOptionPane;
    import javax.swing.JDialog;
    import javax.swing.JButton;
    import javax.swing.JRadioButton;
    import javax.swing.ButtonGroup;
    import javax.swing.JLabel;
    import javax.swing.ImageIcon;
    import javax.swing.BoxLayout;
    import javax.swing.Box;
    import javax.swing.BorderFactory;
    import javax.swing.border.Border;
    import javax.swing.JTabbedPane;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.*;
    //import java.Original.*;
    //import java.Turtle.*;
    //import jav.Turtle.galapagos.*;
    public class JavaMenu extends JPanel
         JFrame frame;
         JLabel label;
         JButton select;
         String labDescription = "Java labs created in class.";
         String turtleDescription = "Turtle labs created in class";
         String creationDescription = "Java programs created on my own.";
         public JavaMenu(JFrame frame)
              super(new BorderLayout());
              JPanel lab = labDialog();
              //JPanel turtle = turtleDialog();
              //JPanel creation = creationDialog();
              label = new JLabel("Click Select Program to run the program.", JLabel.CENTER);
              this.frame = frame;
              Border padding = BorderFactory.createEmptyBorder(20,20,5,20);
              lab.setBorder(padding);
              //turtle.setBorder(padding);
              //creation.setBorder(padding);
              JTabbedPane tab = new JTabbedPane();
              tab.addTab("Java Labs", null, lab, labDescription);
              //tab.addTab("Turtle Labs", null, turtle, turtleDescription);
              //tab.addTab("Java Programs", null, creation, creationDescription);
              add(tab, BorderLayout.CENTER);
              add(label, BorderLayout.PAGE_END);
              label.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
         void setLabel(String newText)
              label.setText(newText);
         protected static ImageIcon createImageIcon(String path)
            java.net.URL imgURL = JavaMenu.class.getResource(path);
            if (imgURL != null) {
                return new ImageIcon(imgURL);
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
         private JPanel labDialog()
              final int numButtons = 25;
              JRadioButton[] javalabs = new JRadioButton[numButtons];
              final ButtonGroup group = new ButtonGroup();
              select = null;
              final String messageCommand2 = "Lab 02";
              final String messageCommand3 = "Lab 03";
              final String messageCommand4 = "Lab 04";
              final String messageCommand41 = "Lab 04 Extra Credit 1";
              final String messageCommand42 = "Lab 04 Extra Credit 2";
              final String messageCommand5 = "Lab 05";
              final String messageCommand51 = "Lab 05 Extra Credit";
              final String messageCommand6 = "Lab 06";
              final String messageCommand6b = "Lab 06";
              final String messageCommand7 = "Lab 07";
              final String messageCommand71 = "Lab 07 Extra Credit";
              final String messageCommand8 = "Lab 08";
              final String messageCommand8b = "Lab 08";
              final String messageCommand81 = "Lab 08 Extra Credit";
              final String messageCommand9 = "Lab 09";
              final String messageCommand9b = "Lab 09";
              final String messageCommand91 = "Lab 09 Extra Credit 1";
              final String messageCommand92 = "Lab 09 Extra Credit 2";
              final String messageCommand93 = "Lab 09 Extra Credit 3";
              final String messageCommand9a = "Lab 09 American Flag";
              final String messageCommand9t = "Lab 09 Texas Flag";
              final String messageCommand0 = "Lab 10";
              final String messageCommand0b = "Lab 10 Hi Lo Game";
              final String messageCommand01 = "Lab 10 Extra Credit 1";
              final String messageCommand02 = "Lab 10 Extra Credit 2";
              javalabs[0] = new JRadioButton("Lab 02 100 Point Version");
              javalabs[0].setActionCommand(messageCommand2);
              javalabs[1] = new JRadioButton("Lab 03 100 Point Version");
              javalabs[1].setActionCommand(messageCommand3);
              javalabs[2] = new JRadioButton("Lab 04 100 Point Version");
              javalabs[2].setActionCommand(messageCommand4);
              javalabs[3] = new JRadioButton("Lab 04 Extra Credit 1");
              javalabs[3].setActionCommand(messageCommand41);
              javalabs[4] = new JRadioButton("Lab 04 Extra Credit 2");
              javalabs[4].setActionCommand(messageCommand42);
              javalabs[5] = new JRadioButton("Lab 05 100 Point Version");
              javalabs[5].setActionCommand(messageCommand5);
              javalabs[6] = new JRadioButton("Lab 05 Extra Credit");
              javalabs[6].setActionCommand(messageCommand51);
              javalabs[7] = new JRadioButton("Lab 06A 100 Point Version");
              javalabs[7].setActionCommand(messageCommand6);
              javalabs[8] = new JRadioButton("Lab 06B 100 Point Version");
              javalabs[8].setActionCommand(messageCommand6b);
              javalabs[9] = new JRadioButton("Lab 07 100 Point Version");
              javalabs[9].setActionCommand(messageCommand7);
              javalabs[10] = new JRadioButton("Lab 07 Extra Credit");
              javalabs[10].setActionCommand(messageCommand71);
              javalabs[11] = new JRadioButton("Lab 08A 100 Point Version");
              javalabs[11].setActionCommand(messageCommand8);
              javalabs[12] = new JRadioButton("Lab 08B 100 Point Version");
              javalabs[12].setActionCommand(messageCommand8b);
              javalabs[13] = new JRadioButton("Lab 08 Extra Credit");
              javalabs[13].setActionCommand(messageCommand81);
              javalabs[14] = new JRadioButton("Lab 09A 100 Point Version");
              javalabs[14].setActionCommand(messageCommand9);
              javalabs[15] = new JRadioButton("Lab 09B 100 Point Version");
              javalabs[15].setActionCommand(messageCommand9b);
              javalabs[16] = new JRadioButton("Lab 09 Texas Flag");
              javalabs[16].setActionCommand(messageCommand9t);
              javalabs[17] = new JRadioButton("Lab 09 American Flag");
              javalabs[17].setActionCommand(messageCommand9a);
              javalabs[18] = new JRadioButton("Lab 09 Extra Credit 1");
              javalabs[18].setActionCommand(messageCommand91);
              javalabs[19] = new JRadioButton("Lab 09 Extra Credit 2");
              javalabs[19].setActionCommand(messageCommand92);
              javalabs[20] = new JRadioButton("Lab 09 Extra Credit 3");
              javalabs[20].setActionCommand(messageCommand93);
              javalabs[21] = new JRadioButton("Lab 10 A 100 Point Version");
              javalabs[21].setActionCommand(messageCommand0);
              javalabs[22] = new JRadioButton("Lab 10 B 100 Point Version");
              javalabs[22].setActionCommand(messageCommand0b);
              javalabs[23] = new JRadioButton("Lab 10 Extra Credit 1");
              javalabs[23].setActionCommand(messageCommand01);
              javalabs[24] = new JRadioButton("Lab 10 Extra Credit 2");
              javalabs[24].setActionCommand(messageCommand02);     
              for (int k = 0; k < numButtons; k++)
                   group.add(javalabs[k]);
              javalabs[0].setSelected(true);
              select = new JButton("Select Program");
              select.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        String command = group.getSelection().getActionCommand();
                        if (command == messageCommand2)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                 try
                                    Runtime.getRuntime().exec(new String[] {"cmd", "set classpath=D:/Documents and Settings/Yinon Michaeli/My Documents/CS/java/Labs02", "path C:/j2sdk1.4.0/bin", "java Lab020"});
                                    //File file = new File("java/Labs02");
                                    //Runtime.getRuntime().exec(new String[] {"rundll32", "url.dll,FileProtocolHandler","file:///" + file.getAbsolutePath()});
                                 catch (Exception a)
                                      JOptionPane.showMessageDialog(frame, "Error: Exception.", "Error", JOptionPane.ERROR_MESSAGE);
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand3)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand4)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand41)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand42)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand5)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand51)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand6)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand6b)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand7)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand71)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand8)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand8b)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand81)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand9)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand91)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand9t)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand9a)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand9b)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand92)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand93)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand0)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand0b)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand01)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        if (command == messageCommand02)
                             int confirm = JOptionPane.showConfirmDialog(frame, "You are about to run the program, o.k.?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                             if (confirm == JOptionPane.YES_OPTION)
                                  setLabel("Awesome!");
                             else if(confirm == JOptionPane.NO_OPTION)
                                  setLabel("You've got to be kidding!");
                        return;
              return create2ColPane(labDescription + ":", javalabs, select);     
         private JPanel createPane(String description, JRadioButton[] radioButtons, JButton showButton)
              int numChoices = radioButtons.length;
            JPanel box = new JPanel();
            JLabel label = new JLabel(description);
            box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS));
            box.add(label);
            for (int k = 0; k < numChoices; k++)
                box.add(radioButtons[k]);
            JPanel pane = new JPanel(new BorderLayout());
            pane.add(box, BorderLayout.PAGE_START);
            pane.add(showButton, BorderLayout.PAGE_END);
            return pane;
        private JPanel create2ColPane(String description, JRadioButton[] radioButtons, JButton showButton)
            JLabel label = new JLabel(description);
            int numPerColumn = radioButtons.length/2;
            JPanel grid = new JPanel(new GridLayout(0, 2));
            for (int k = 0; k < numPerColumn; k++)
                grid.add(radioButtons[k]);
                grid.add(radioButtons[k + numPerColumn]);
            JPanel box = new JPanel();
            box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS));
            box.add(label);
            grid.setAlignmentX(0.0f);
            box.add(grid);
            JPanel pane = new JPanel(new BorderLayout());
            pane.add(box, BorderLayout.PAGE_START);
            pane.add(showButton, BorderLayout.PAGE_END);
            return pane;
        private static void createAndShowGUI()
             JFrame.setDefaultLookAndFeelDecorated(true);
             JFrame frame = new JFrame("Java Programs");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JavaMenu newContentPane = new JavaMenu(frame);
            newContentPane.setOpaque(true);
            frame.setContentPane(newContentPane);
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args)
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

    Why are you posting hundreds of lines of code not related to the problem??? 99.9% of the code you posted has absolutely nothing to do with using the Runtime.exec() method.
    Create a simple test program that simply tries to invoke the Runtime.exec() method. Once you get that working, then you incoporate it into you real program. Don't clutter the forum with unnecessary code.
    public class WindowsFileProtocolHandler
         public static void main(String[] args)
              throws Exception
              String[] cmd = new String[4];
              cmd[0] = "cmd.exe";
              cmd[1] = "/C";
              cmd[2] = "java";
              cmd[3] = "YourClassHere";
              Process process = Runtime.getRuntime().exec( cmd );
    }

Maybe you are looking for

  • Problems with new MacBook Pro when using Front Row

    I posted this in the MacBook Pro forum, but someone suggested I post it here, so here goes... I just picked up a new 15" MacBook Pro 2.4 last night. I was very excited, as I've wanted one for a while now, but when I tried to watch a dvd in Front Row

  • Problem with Multiple Context Creation

    Hi, We are facing a java.lang.SecurityException Invalid Subject We need to create multiple Initial Contexts for a single thread. Following is the Scenario 1) The user will access Servlet/Struts Action class which performs database call and EJB(one, t

  • Uhhh... My iMac has no Video Card?

    So I bought a 20' inch 2.4 Ghz iMac with 2 GB of memory because I knew I'd be playing games... But I downloaded Aspyr's Game Agent and all games came up as unplayable because I had no video card........... Are you kidding me........?

  • Is it possible to animate videos and images coming from web service.

    i am calling a webservice. from that i am getting response. in that i have images and videos. i took those in an array. Now i need to animate those array values. just like animating images. So please tell me is it possible to animate videos are not.

  • Phone and SMS stop working.

    Sometimes (it's at random and for chunks of time) I will be unable to send text messages. The progress bar will get 90% then hang up and a message will pop up saying "Error Sending Message" and I will have to try again repeatedly until it finally dec