| Author |
Calling Java program from Non-Java code
|
mini mehta
Ranch Hand
Joined: Oct 22, 2000
Posts: 120
|
posted

0
|
Hi Is there any way to call java code from non-java and return a exit code from java program to non-java program. example calling a java batch program from a shell script. Thanks
|
 |
Jan Cumps
Bartender
Joined: Dec 20, 2006
Posts: 2343
|
|
Yes. You can call your java program just like any other program. To return a status code to the calling program, use System.exit(n). Regards, Jan
|
OCUP UML fundamental
ITIL foundation
|
 |
rohit leeta
Ranch Hand
Joined: May 02, 2007
Posts: 49
|
posted

0
|
|
If Jan's solution does not work for you you can learn JNI api. It allows you to crease a JVM and run Java programs from C/C++ programs.
|
<a href="http://www.java-forums.org" target="_blank" rel="nofollow">Java Forums</a>
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6588
|
|
Originally posted by mini mehta: Hi Is there any way to call java code from non-java and return a exit code from java program to non-java program. example calling a java batch program from a shell script. Thanks
You could have a java function called from your program through the use of JNI
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Jan Cumps
Bartender
Joined: Dec 20, 2006
Posts: 2343
|
|
I was aiming for the simplest solution, because the requestor was asking for a shell script example. The shell script could look like this (unix-like pseudocode): where the environment variable $? holds the value returned by the java program. Regards, Jan
|
 |
 |
|
|
subject: Calling Java program from Non-Java code
|
|
|