Combining Java and C without gcj -- move C to Java or Java to C? -


First of all, I have no experience doing this. But like the introduction of any good program, I have a problem that needs to be corrected, so I am ready to learn.

So many of you are already familiar with PDFTK, different PDF-related tasks, as far as I can tell that most of these features are available in newer, lighter libraries / extensions Available, except for one (and perhaps its only reason still exists): Merge form data files (FDF and XFDF) with a form, PDF and output as a new file.

The problem is that my server does not have GCJ, which is fundamental to creating / compiling PDFTK. I do not know if this is because I am on Solaris or if it is due to some other Sesadmin level, but I am not getting GCJ anytime soon. And as far as I can get there, there are no pre-compiled binaries for Solaris.

So I think the Mac file and C code can be rewritten to import the Java Library. ) Straight through Javac.

But I'm not sure where exactly to start from. I know everything:

  1. When I am doing, I would like a binary so that neither JavaMM required for every use.
  2. The current app uses GCJ. So my first thought was "Oh it is easy, maybe I can call classes with some other C-based methods", but instead of finding a simple method to do this For, I'm looking for a long post on different angles, which can be contacted, etc.

    Then I found a page on the Sun's site, to call other languages ​​(eg C) is a Java class but there are problems with that approach:

    1. Cover me
    2. Maybe I skipping that part and talking in full writing in Java
    3. I am not ready for it yet if I can only import those classes Already exists I
    4. I'm not clear if I have compiled and received Is can I end a binary or if I have all the time need Java trapped me.

    Again, I apologize for my ignorance. I just need some advice and examples about how GCJ-dependent C code will be replaced, which works directly with Java.

    And of course if I'm asking one of them "If we can do this, then let me know," Be already rich "type question.

I'm not sure what you're all right, so I have given many answers.


If you have a Java code that needs to be run, you should:

  1. Run it in a jvm. You can start that vm in your own custom c-code, but this Still a jvm
  2. Compile with a timer compiler (such as GCJ)

Incidentally, you compile a copy of the GCJ in your home folder I can understand that the magic switch is - enabled-languages ​​= Java, C (see: for more)


If you have a C-code that you want to call from Java, you have four options:

  1. Java Basic Interface (JNI) A Received that you found it
  2. Java Native Access (Jeana) is slower than Jeanai, but less coding and does not require a cover C-code. It requires jars and a library.
  3. Create a CLI utility and use Runtime.exe (...) to call it.
  4. Use any type of inter process communication Java code asks for C-code to perform operations and return results.

Additional platform dependent options

  1. Use JACOB (Win32: Com access only)

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -