DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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, 12:54 AM
  2. passing args to querystring
    By anuj in forum ASP.NET
    Replies: 1
    Last Post: 02-01-2002, 01:32 PM
  3. Passing parameters to the "main" method
    By Andrew McLellan in forum Java
    Replies: 4
    Last Post: 12-07-2001, 02:55 PM
  4. Replies: 0
    Last Post: 09-06-2001, 01:29 AM
  5. Replies: 6
    Last Post: 03-04-2001, 09:56 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links