Commit 5fcfa158 authored by Martin Deinhofer's avatar Martin Deinhofer
Browse files
parents 749e854e 8037a2c2
......@@ -8,38 +8,32 @@ At times, it is necessary to use native codes (C/C++) to overcome the memory man
2. **C/C++ Compiler**
* GCC compiler and Makefile ([Read "GCC and Make"]( **or**
* Cygwin or MinGW on Windows ([Read "How to Setup Cygwin and MinGW](
3. **Eclipse for Java Developers** with **C/C++ Development Tool (CDT) extension** installed ([Read "Eclipse CDT"](
# Clone project
```git clone```
# Create Eclipse project
1. *File/New/Project*
2. Select *General/Project* and click *Next*
3. Unselect *Use default location* and browse to cloned diretory, click *OK*
4. Enter *Project name* and click *Finish*
# Build project
Building the project involves two steps
1. Building Java code
* Click on *Project/Build All*. This is not necessary if *Build Automatically* is selected.
2. Building native code either on command line or using the configured Eclipse build targets
* Command line:```cd jni && make``` or
* Double click on *jni/Build Targets/all*
2. Building native code
These tasks are done in the makefile, so call:
```cd jni && make```
# Run project
Before the application can be run, you must build the native code and provide the library path to the "hello.dll" file, if it is not located in the *current working directory*.
This can be done via the VM argument ```-Djava.library.path```. Right-click on the project and select *Run As/Run Configurations*, then select *Java Application*. In the *Main tab*, enter the main class "HelloJNI" and in *Arguments/VM Arguments*, enter ```-Djava.library.path=jni```. Finally click on *Run*.
You should see the output "Hello World!" displayed on the console.
This can be done via the VM argument ```-Djava.library.path```.
## Command line
```java -Djava.library.path=jni -cp bin java_exercises7_1_1.HelloJNI```
```java -cp bin -Djava.library.path=jni java_exercises8_1_1.HelloJNI```
or using the makefile
```cd jni && make run```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment