Jump to content
Sign in to follow this  
FitzChivalry

Run java program with cmd args?

Recommended Posts

FitzChivalry

So I have a .jar file that I'm trying to run with some command line arguments from autoit. My java program works fine from the console when I type in "java -jar email.jar filename", but I can't get it to run directly from autoit. I've tried:

Run("C:\Documents and Settings\AllisonRS\email\dist\java -jar email.jar X:\Apps\labchecklogs\Daily\20070605oklog.txt")

Run(@ComSpec & " /c " & 'C:\Documents and Settings\AllisonRS\email\dist\java -jar email.jar X:\Apps\labchecklogs\Daily\20070605oklog.txt', "", @SW_HIDE)

ShellExecute("C:\Documents and Settings\AllisonRS\email\dist\java -jar email.jar X:\Apps\labchecklogs\Daily\20070605oklog.txt")

and some other things that i cant quite remember exactly what. The point is, my java program never ran correctly. I've done some searching around on the forums here, and it seems it can be done by writing to a batch file and running that, but that is not something i want to do. The cmd argument filename will be a variable, just wondering if anyone has any experience using autoit with java. I'm pretty sure it is something simple, but I have been working on this problem for a while and can't seem to think straight anymore. Any help would be appreciated. Thanks!

Share this post


Link to post
Share on other sites
FitzChivalry

no it does not... it throws the error:

Run("C:\docs and settings\..\..\dist\java -jar email.jar")

Error: unable to execute the external program.

The system cannot find the file specified.

[edit]

when i run the jar from console, it throws ArrayOutOfBounds exception because there is no cmdline arg

[/edit]

Edited by FitzChivalry

Share this post


Link to post
Share on other sites
PsaltyDS

no it does not... it throws the error:

Run("C:\docs and settings\..\..\dist\java -jar email.jar")

Error: unable to execute the external program.

The system cannot find the file specified.

[edit]

when i run the jar from console, it throws ArrayOutOfBounds exception because there is no cmdline arg

[/edit]

The file type .jar is not directly executable, ShellExecute() or Run(@ComSpec & " /c START " & ...etc.).

:)

Edit: Example:

$JavaDir = "C:\Documents and Settings\AllisonRS\email\dist"
ShellExecute($JavaDir & "\email.jar", "X:\Apps\labchecklogs\Daily\20070605oklog.txt", $JavaDir)
Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
FitzChivalry

I figured it out after sleeping on it one more time. The correct command is:

Run("java -jar email.jar " & $text, "C:\Documents and Settings\AllisonRS\email\dist\")

I just had to set the working directory, I remember that messed me up in a couple other programs as well... thanks for the help everyone!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×