Jump to content

Run java program with cmd args?


Recommended Posts

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!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...