It's not a secret anymore!
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "call java program from script?" Watch "call java program from script?" New topic

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?

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

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:

I agree. Here's the link:
subject: call java program from script?
It's not a secret anymore!