Two Laptop Bag*
The moose likes C / C++ and the fly likes Running a Java Program from a C program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Running a Java Program from a C program" Watch "Running a Java Program from a C program" New topic

Running a Java Program from a C program

Arka Sharma
Ranch Hand

Joined: Jun 15, 2011
Posts: 103


I have written a C program.Inside that i have called system("java JavaProg");.It is working fine but still the java process is terminated the C process is running.I want when the java process terminates normally or abruptly C process should automatically terminate.How to do it ?

Rob Spoor

Joined: Oct 27, 2005
Posts: 19651

Can you show the part of the C program that runs the Java program?

How To Ask Questions How To Answer Questions
Brian Overland
Ranch Hand

Joined: Sep 09, 2011
Posts: 36
Yes, I would need to seed the C program as well. You may need to make sure that the main() function is declared as int, and returns 0 to the operating system... or you may even need to exit explicitly by call an op-sys function. That's what springs to my mind.

I wish I knew more about the paticular code and the environment from which you are running.

I agree. Here's the link:
subject: Running a Java Program from a C program
Similar Threads
All Classes in a Package?
running external program from Java
Using native code
Calling Java Methods in a windows java service
Need some advice on returning record sets from a web service to a C# client.