• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java call to C++

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing a Web Crawler program and the GUI is written in Java. I am having trouble figuring out a way to call C++ from the GUI. I have text fields where the user can specify a search query and a starting URL in order to search. The GUI then needs to send that data to C++ as strings. I cannot figure out any system calls or whatever I need in order to call my C++ program. Any help would be greatly appreciated. Thanks in advance.
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked into JNI?

I don't actually know anything about calling C++ from Java (I've only called COBOL personally) that's just an educated guess as to where a good place to start is.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, JNI is the way to call C++ (or C) from Java. Search java.sun.com Web site for information and tutorials.

Most tutorial information tends to be about using C. You can write your C++ in a C-like way, and it will work fine. But do search out the C++-specific features of JNI, because they make things a bit tidier.

Typically, you will not be able to call your existing C++ code directly from Java. It is usual to end up writing a C++ wrapper around your existing C++ code, to give it a JNI-compatible interface.
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic