vladsoroka / gradlejnisample Goto Github PK
View Code? Open in Web Editor NEWA sample application that shows how to use Gradle to compile and run C/C++ JNI code
A sample application that shows how to use Gradle to compile and run C/C++ JNI code
My java file
public class HelloWorld {
public native void print();
static {
System.loadLibrary("hello");
}
public static void main(String[] args) {
new HelloWorld().print();
}
}
OUTPUT
10:30:26: Executing task 'HelloWorld.main()'...
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :HelloWorld.main() FAILED
2 actionable tasks: 2 executed
java.lang.UnsatisfiedLinkError: no hello in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:871)
at java.lang.System.loadLibrary(System.java:1124)
at HelloWorld.<clinit>(HelloWorld.java:5)
Exception in thread "main"
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':HelloWorld.main()'.
> Process 'command 'C:/Program Files/OpenJDK/openjdk-8u292-b10/bin/java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to
get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
10:30:33: Task execution finished 'HelloWorld.main()'.
How can I solve this ?
If I use c++ code it comes an error.
When I run I have the following error.
C:\Users\pja\Documents\GradleJniSample-master>gradlew test
> Task :hello:compileDebugCpp FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':hello:compileDebugCpp'.
> No tool chain is available to build C++ for host operating system 'Windows 10' architecture 'x86-64':
- Tool chain 'visualCpp' (Visual Studio):
- Could not locate a Visual Studio installation, using the command line tool, Windows registry or system path.
- Tool chain 'gcc' (GNU GCC):
- Could not find C++ compiler 'g++' in system path.
- Tool chain 'clang' (Clang):
- Could not find C++ compiler 'clang++' in system path.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --
scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
3 actionable tasks: 1 executed, 2 up-to-date
How can I solve this error ?
Hello, I have successfully run this project with ./gradlew test
.
Then when I try to run new HelloWorld().print()
in java main class using IntelliJ's Run button, it failed with the following message:
Execution failed for task ':Script.main()'.
> Process 'command '/Users/frank/Library/Java/JavaVirtualMachines/adopt-openjdk-11.0.8/Contents/Home/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Here is my Script.java file definition in the same folder of HelloWorld.java:
public class Script {
public static void main(String[] args) {
new HelloWorld().print();
}
}
Do you know how do fix it? Thanks for your reply!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.