项目作者: apsrcreatix

项目描述 :
15IT411J Integrative Programming And Technology Laboratory
高级语言: Java
项目地址: git://github.com/apsrcreatix/15IT411J-IPT.git
创建时间: 2018-08-13T09:47:06Z
项目社区:https://github.com/apsrcreatix/15IT411J-IPT

开源协议:

下载


15IT411J Integrative Programming And Technology Laboratory

1. Instructions for Java Native Interface

This section is only for 00-03 titled experiments (JNI related
) in this repository.

1.1 Requirements

  1. A Java Compiler “javac” which ships with the SDK
  2. A Java Virtual Machine “java” which ships with the SDK
  3. A native method c header file generator “javah” which ships with the SDK.
  4. A C/C++ compiler “cc” that can create shared library

1.2 Steps for output

To run the program related java native interface follow the following commands for linux on terminal :

  1. Compile the java code.
    • A
      • Java file name.
  1. javac A.java
  1. Create C/C++ header file.
    • A
      • class file name.
  1. javah A
  1. Create a shared library file using the C/C++ file created using terminal.

    • A

      • Put lib and then the name for the file written inside the .java file under static block.

      • Example - JNIDemo.java

          1. static
          2. {
          3. System.loadLibrary("JNIDemo");
          4. }

          Then library file’s name should be libJNIDemo.so

    • B

      • C file name.
    • How to get jdk folder path in linux

      • If you don’t have jdk1.8.0* then follow these commands if you are using ubuntu or any debian based distro :

          1. sudo apt-get update
          1. sudo apt install default-jdk

          Enter password (if you have) and Press Y/y

      • Go to root directory and search for jdk1.8.0 or a file jni.h

      • You may get the folder then can copy the path for include folder and linux folder

  1. gcc -fPIC -I"/usr/java/jdk1.8.0_181/include" -I"/usr/java/jdk1.8.0_181/include/linux" --shared -o A.so B.c
  1. Run the java program.
    • A
      • Name of class file.
  1. java -Djava.library.path=. A

1.3 Reference

REFERENCE FOR MORE CODE

2. Instructions for Beans

This section will show you how to use these projects (04 - 07)

2.1 Non Visual Bean Project

For 04-jb-non-visual-bean

  • If you are a IntelliJ IDEA user then directly import the project or open this project in IDE.
  • If you are a Netbeans user then follow the steps :
    • Create a new project.
    • Choose JavaFx Application.
    • Name the project whatever you want and finish.
    • Go to workspace directory of Netbeans and delete src folder.
    • Paste src folder from 04-jb-non-visual-bean
    • Build and run the project now.