Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2008
    Posts
    11
    Rep Power
    0

    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?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    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.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,307
    Rep Power
    25

    Default

    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.

  4. #4
    Join Date
    Sep 2008
    Posts
    11
    Rep Power
    0

    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?

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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 06:40 AM.

  6. #6
    Join Date
    Sep 2008
    Posts
    11
    Rep Power
    0

    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.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    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.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,307
    Rep Power
    25

    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?

  9. #9
    hanifa is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    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

Similar Threads

  1. Java Programming Tutorial
    By levent in forum Java Tutorial
    Replies: 1
    Last Post: 07-04-2008, 08:15 AM
  2. java game programming
    By gammaman in forum New To Java
    Replies: 1
    Last Post: 12-25-2007, 01:01 AM
  3. Java networking programming (I)
    By Java Tutorial in forum Java Tutorial
    Replies: 0
    Last Post: 12-24-2007, 07:21 PM
  4. Java Applet 3D programming
    By ramk in forum Java Applets
    Replies: 0
    Last Post: 11-28-2007, 10:36 PM
  5. Java Programming
    By JavaForums in forum Java Tutorial
    Replies: 0
    Last Post: 07-28-2007, 11:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •