Jump to content

Linking C++ and Java

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
strowa65

strowa65

    Newbie

  • Members
  • Pip
  • 4 posts
Hi,

I've written my source code in C++. I want to link it with an applet which will accept the input and show the output. Is it possible or, do i have to convert my source code to java

#2
G_Morgan

G_Morgan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 537 posts
I'm not sure it can be done via an applet because the class files are downloaded locally.

You can link it into a Java application via JNI but unless you have a load of code I wouldn't bother and would rewrite it in Java.

#3
strowa65

strowa65

    Newbie

  • Members
  • Pip
  • 4 posts
it is nearly 1000 lines of code...and i know just the basics of java, so will learning JNI take time? I have a deadline too...

#4
G_Morgan

G_Morgan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 537 posts
That's probably borderline. JNI is doable but like I said, it doesn't work with applets.

Interfacing C with Java in Linux - The JNI Solution

That shows you how to link C code with Java. Shouldn't be too difficult to expand it to C++.

Putting a Java Interface on your C, C++, or Fortran Code

Here's another guide that works in more general terms.