This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 15286
    
    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 - A Test Data Generation Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling C programs from java
 
Similar Threads
Java 2D & 3D
How To Write Terminate and Stay Resident Programs
Is C# really a programming language?
Pring API suggestion needed
Is it possible to run C and C++ code in JVM ?