Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > running command line commands with arguments...

Reply
Thread Tools

running command line commands with arguments...

 
 
doneirik
Guest
Posts: n/a
 
      02-16-2007
Dear forum,

I need to run a command line like command with arguments in the java
code.
Now I have things stored in a .bat file that I execute , however, I
would like to run everything from the java code itself. Would that be
possible?

java code:
Runtime r = Runtime.getRuntime();
try
{
String s = "latTest.bat";
r.exec(s);
}
catch (Exception ioe)
{}

bat file:

@ECHO OFF

cd c:\Program files\MikTex 2.5
pdflatex C:\Temp\testfile.tex
testfile.pdf

 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      02-16-2007
On 15 Feb 2007 23:19:31 -0800, doneirik wrote:
> I need to run a command line like command with arguments in the java
> code. Now I have things stored in a .bat file that I execute ,
> however, I would like to run everything from the java code itself.
> Would that be possible?


Yes. Have you not read the API documentation for Runtime.exec()?

String cmd = "pdflatex C:\\Temp\\testfile.tex testfile.pdf"
File dir = new File("C:\\Program files\MikTex 2.5");
Process p = Runtime.getRuntime().exec(cmd, null, dir);

/gordon

--
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
commands.getstatusoutput result is not command line exit value!!! Hari Sekhon Python 0 10-02-2006 02:45 PM
Command-line tool able to take multiple commands at one time? Peter A. Schott Python 8 11-12-2005 12:53 AM
Re: How to run commands in command line from a script Ivan Shevanski Python 1 07-01-2005 03:53 PM
Re: How to run commands in command line from a script Ivan Shevanski Python 3 07-01-2005 01:42 PM
How to run commands in command line from a script Ivan Shevanski Python 1 07-01-2005 03:09 AM



Advertisments