GeeCON Prague 2014*
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
Author

calling C programs from java

Steve Matthews
Greenhorn

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,
bigSteve
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
bigSteve
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!!


Dave
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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:
http://java.sun.com/docs/books/tutorial/native1.1/index.html
Hope that helps.


GenRocket - Experts at Building Test Data
 
GeeCON Prague 2014
 
subject: calling C programs from java