Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-05-2008, 05:07 PM
Member
 
Join Date: Sep 2008
Posts: 3
Rep Power: 0
kapil1089theking is on a distinguished road
Wink interface C programming with Java
I have designed an application, whenever I press a button it should execute the c code in the same folder how to achieve it?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 09-06-2008, 05:05 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,452
Rep Power: 8
Fubarable is on a distinguished road
Default
You will need to compile the C-code with the correct settings and interface it with Java using JNI. There are tutorials on this, but understand that this is not trivial programming and will take some work to get to understand.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 09-06-2008, 03:32 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
execute the c code
If the c code is executeable from a command prompt, then you could use the Process and Runtime classes to execute it from a java program.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 09-07-2008, 07:27 AM
Member
 
Join Date: Sep 2008
Posts: 3
Rep Power: 0
kapil1089theking is on a distinguished road
Default Tell me the step by step procedure
I have developed the c program on linux and I have j2se installed on my windows now I need To make a GUI wrapper to the c program, which will do good with linux and windows both... 1st help me so that i can develop the same/application on XP, tell me the step by step procedure to achieve the same.

Do I need and c compiler with java?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 09-07-2008, 07:38 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,452
Rep Power: 8
Fubarable is on a distinguished road
Default
Quote:
I have developed the c program on linux and I have j2se installed on my windows now I need To make a GUI wrapper to the c program, which will do good with linux and windows both... 1st help me so that i can develop the same/application on XP, tell me the step by step procedure to achieve the same.
You really don't understand the magnitude of what you are asking here. Let me help you. Go to these tutorials on JNI:
CodeProject: JNI Basics - 1. Free source code and programming help
Chapter 5: JNI Technology
Java Native Interface: Programmer's Guide and Specification

Read and study them, and then come back in about a month, maybe longer.

Also, one more thing: using JNI often breaks your program's platform independence.

Lots of luck.

Last edited by Fubarable; 09-07-2008 at 07:40 AM.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 09-07-2008, 07:51 AM
Member
 
Join Date: Sep 2008
Posts: 3
Rep Power: 0
kapil1089theking is on a distinguished road
Default If that is so hard....
Sorry Fub for askin you a qn with such a big answer, if making it in java is so tough then could you suggest me a better way to have a gui wrapper for c in linux?

and tell me the same if I do it for windows?
Simplicity of the wrapping language is one of the preferences.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 09-07-2008, 08:01 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,452
Rep Power: 8
Fubarable is on a distinguished road
Default
Let me correct myself. If you are a wiz at C++, then you'll probably catch on to JNI pretty quickly. Us mere mortals may take longer.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 09-07-2008, 03:15 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
How do you plan to communicate between the C program and the java program? Will the interface require more than what would go on a commandline or be printed to a std out?
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 09-11-2008, 06:09 AM
Member
 
Join Date: Sep 2008
Posts: 7
Rep Power: 0
hanifa is on a distinguished road
Default
Hi,
Try using swig.I cant post the link cos the the forum only allows you to post a link once you make 20 posts. But just google for Swig, you should be able to find it easily. Using Swig, it can easily convert C/C++ code into java by generating the JNI for you. Isnt that great.
I have used it to interface my C++ code with Java Swing.

Hope it helps.
Cheers
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Programming Tutorial levent Java Tutorials 1 07-04-2008 09:15 AM
java game programming gammaman New To Java 1 12-25-2007 02:01 AM
Java networking programming (I) Java Tutorial Java Tutorials 0 12-24-2007 08:21 PM
Java Applet 3D programming ramk Java Applets 0 11-28-2007 11:36 PM
Java Programming JavaForums Java Tutorials 0 07-29-2007 12:10 AM


All times are GMT +2. The time now is 10:43 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org