Ben Chuanlong Du's Blog

It is never too late to learn.

Call Java Code Using JPype from Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

JPype is easy and intuitive to use. It is the most popular Java interface for Python currently.

import os
import sys
from pathlib import Path
import jpype


jpype.addClassPath("/path/to …

General Tips for Gradle

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Install & Upgrade Gradle

The latest version of gradle can be installed via PPA on Ubuntu.

sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update

And gradle can be upgraded using the following …

Java Native Access

Java Native Interface

  1. You can call native code (typically C, C++ or Fortran) in Java using the Java Native Interface (JNI). For the code implemented in native code, you must use keyword "native" to tell the compiler that it is implemented outside Java. Also, you should surround the Java code which load the compile native code in static{}

String in Java

Comments

  1. String is a immutable class in Java. Extensive operations on strings (e.g., + in a big loop) is usually very slow before Java 7 (the + operator is optimized by the compiler automatically starting from Java 7). To avoid this problem (in older versions of Java), you can use the StringBuilder