Passing args with Runtime.exec()


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Passing args with Runtime.exec()

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Posts
    1

    Passing args with Runtime.exec()

    Hello,

    I am having a problem passing arguments to a Java application. If I run it from command prompt, I can just input the following:

    Java IRC -NICK GV_CONTROLLER82 -INSTRUCTOR Spiro -SESSIONID 82

    And it works perfectly.

    However I need to execute the java IRC application from another java app. I do this by using Runtime.exec(). It works if I donít send the arguments.

    I need to know how to send the above arguments to using runtime.exec()

    Please Help!

    This is the code segment below:

    Code:
    private void SessionStart() {
    	String[] cmd = {"java","IRC -NICK GV_CONTROLLER82 -INSTRUCTOR Spiro -SESSIONID 82"};
    		     
    		    try
    	        {            
    	            Runtime rt = Runtime.getRuntime();
    	            Process proc = rt.exec(cmd);
    	            int exitVal = proc.waitFor();
    
    	            System.out.println("Process exitValue: " + exitVal);
    	        } catch (Throwable t)
    	        {
    	            t.printStackTrace();
    	        };
         
      }

  2. #2
    Join Date
    Aug 2004
    Posts
    46

  3. #3
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    try breaking the second string up into strings of a single word each vs putting them all in one string.

Similar Threads

  1. Replies: 1
    Last Post: 02-28-2002, 01:54 AM
  2. passing args to querystring
    By anuj in forum ASP.NET
    Replies: 1
    Last Post: 02-01-2002, 02:32 PM
  3. Passing parameters to the "main" method
    By Andrew McLellan in forum Java
    Replies: 4
    Last Post: 12-07-2001, 03:55 PM
  4. Replies: 0
    Last Post: 09-06-2001, 02:29 AM
  5. Replies: 6
    Last Post: 03-04-2001, 10:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center