Two Laptop Bag*
The moose likes Beginning Java and the fly likes call java program from script? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "call java program from script?" Watch "call java program from script?" New topic
Author

call java program from script?

david lightman
Ranch Hand

Joined: Nov 03, 2004
Posts: 82
I am a linux newbie but I want to call java program from a shell script

it is a bash shell and is it also possible to pass variables to the java program when it is called?

thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Sure., Just run the program as "java ClassName arg1 arg2 ...", where ClassName is the name of the main class, and arg1, etc, are the command-line arguments to the program. There are, of course, class path issues, etc, but this is the basic idea.


[Jess in Action][AskingGoodQuestions]
Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
You can also launch a jar file, provided it has a manifest that points to the class where the main method is:


--Dale--
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: call java program from script?
 
Similar Threads
Linux script to call a java program
how to execute shell script from java class
Callling a Script from a java program
How to call Java program main method from shell script
ftp files to a different server