Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Example of using C++ classes from Java. Showcases SWIG, JNA and JNI

Notifications You must be signed in to change notification settings

yabbasi31415/java-cpp-example

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example of using C++ code from Java

===================================

Forked from Java-Cpp example

This repository contains an example of calling a simple C++ library from Java code.

The example library doesn't do anything but contains a class, Calculator, forcing us to support C++ (and not just plain C).

CMake is used to build this. The project is supposed to be portable to all major platforms.

A JNI wrapper is used, documented below. Each one achieves the same goal, which is using this C++ class from Java code.

JNI

This examples uses JNI directly, without auto-generation. The Calculator class in Java code just declares its methods as being "native", they are provided by the dynamic library.

To run the executable

$ java -cp java/bin -Djava.library.path=java app.Main

About

Example of using C++ classes from Java. Showcases SWIG, JNA and JNI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CMake 44.3%
  • C++ 41.7%
  • Java 14.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.