my dog learned polymorphism
The moose likes Beginning Java and the fly likes calling C programs from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "calling C programs from java" Watch "calling C programs from java" New topic

calling C programs from java

Steve Matthews

Joined: Apr 18, 2002
Posts: 6
I am a C programmer who has recently cross trained into java. I would like to know how I can call C programs from java. What I have in mind is to create a java GUI wrapper for some rather complex C programs that I do not want to re-write in java!
Any help would be appreciated,
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Well, it all depends on what you mean by call C programs.
If you are just needing to execute a program you wrote in C then you could do the following:

If, however, you need to interface with your program written in C as far as getting reference to objects and/or variables etc, then you would have to use JNI. Here is a link to the JNI tutorial on Sun's Web site:
Hope that helps.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: calling C programs from java
It's not a secret anymore!