Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling C programs from java

 
Steve Matthews
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic