Results 1 to 3 of 3
  1. #1
    gkk
    gkk is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Default Can C++ routines be called from Java program

    Hello,

    I'm sorry if this is a dumb question, but can C++ code/libraries be called within a Java program?

    I'm using Matlab for scientific computing, and a special option may be purchased that outputs an .so file, which can be used as a shared library for standalone C++ code. I wonder if a Java program can access and use such a file?

    Matlab provides the ability to port to Java directly but it's another $4000 option that I'd like to avoid if possible using the above scheme.

    Thanks in advance, -Gkk

  2. #2
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    4

    Default

    It's not a dumb question, not whatsoever.

    Here's a couple links for you to look at; unfortunately I've never done it myself but these look to be exactly what you need.
    Integrating Native Methods into Java Programs
    Java Tip 17: Integrating Java with C++ - JavaWorld
    How to Access C++ from Java | Javalobby

    Best of luck!

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    Oracle have an oldish tutorial on JNI.
    I don't think it's changed significantly since then, but I haven't used it much so can't guarantee.

Similar Threads

  1. Replies: 3
    Last Post: 03-13-2012, 09:28 AM
  2. called external program does not automatically write file
    By nickvandewiele in forum New To Java
    Replies: 6
    Last Post: 02-25-2010, 02:38 PM
  3. update() gets never called
    By flok in forum AWT / Swing
    Replies: 8
    Last Post: 10-19-2009, 04:45 PM
  4. Replies: 0
    Last Post: 09-22-2009, 07:15 PM
  5. My constructor not called
    By rdtindsm in forum New To Java
    Replies: 2
    Last Post: 09-20-2009, 01:38 AM

Posting Permissions

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