Dark Mode

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

Sign up
Appearance settings

Latest commit

History

History
467 lines (297 loc) * 10.1 KB

java.md

File metadata and controls

467 lines (297 loc) * 10.1 KB

Java

NOT PORTED YET.

  • Books
  • SDKman - Install and Manage Multiple Versions of Java at the same time
  • Show Java Classpath
  • Inspect JAR contents
  • JKS - Java Key Store (SSL)
  • Java Decompilers
  • Libraries
    • JitPack.io
  • JShell
  • JBang
    • JBang CLI
  • GraalJS
  • Clojure
  • ProGuard
    • ProGuard Core
    • ProGuard Assembler / Disassembler
    • Kotlin Metadata Printer
    • ProGuard iXGuard
  • JVM Distributions
    • Corretto
    • Gluon
    • GraalVM
    • Java.net
    • JetBrains
    • Liberica
    • Mandrel
    • Microsoft
    • Oracle
    • SapMachine
    • Semeru
    • Temurin
    • Tencent
    • Zulu
  • Memes
    • Books That Made You Cry
    • Porting Your Language to the JVM
    • Imported Package Tariffs
    • Santa, Want Dragon
    • Balancing Dog

Books

Head First Design Patterns

SDKman - Install and Manage Multiple Versions of Java at the same time

See SDKman page.

Show Java Classpath

Since the java -cp / java -classpath is one huge string of colon separated paths, it's nicer to show them one per line using the scripts in DevOps-Bash-tools or DevOps-Perl-tools repos:

java_show_classpath.sh
java_show_classpath.pl

Crude shell pipeline to do similar:

ps -ef |
grep java |
tee /dev/stderr |
awk '{print $2}' |
xargs -L1 jinfo |
grep java.class.path |
tr ':' '\n'

although if it's just jinfo you're missing in the $PATH it would be better to just:

PATH="$PATH:/path/to/bin/containing/jinfo" java_show_classpath.sh

Inspect JAR contents

Java jar files are just tars of the byte-compiled Java classes.

You can inspect them using the good old unix tar command, eg.:

jar tf mysql-connector-j-*.jar

or

tar tvf mysql-connector-j-*.jar

The directory layout of the class files corresponds to the class hierarchy eg. is accessed as com.mysql.jdbc.Driver in Java code.

JKS - Java Key Store (SSL)

See SSL doc.

Java Decompilers

Use these to decompile JAR or .class files to read the Java source code.

Using DevOps-Bash-tools repo:

For a GUI:

jd_gui.sh "$jar_or_class_file"

or

bytecode_viewer.sh

For command line output:

cfr.sh "$jar_or_class_file"

or

procyon.sh "$jar_or_class_file"

Libraries

Some libraries of interest:

  • Faker - generates fake but realistic data for unit testing

JitPack.io

https://jitpack.io/

https://docs.jitpack.io/

Package repo for JVM and Android projects.

Builds Git projects on demand and provides ready-to-use artifacts (jar, aar).

To check if a Jitpack dependency target is valid:

GITHUB_REPO="markomilos/paginate"
VERSION="v1.0.0"
curl -IsSLf "https://jitpack.io/com/github/$GITHUB_REPO/$VERSION/${GITHUB_REPO##*/}-$VERSION.jar"

For an Android dependency, check for the .aar artifact instead of .jar

curl -IsSLf "https://jitpack.io/com/github/$GITHUB_REPO/$VERSION/${GITHUB_REPO##*/}-$VERSION.aar"

Check build log to show what was built by JitPack:

curl "https://jitpack.io/com/github/$GITHUB_REPO/$VERSION/" && echo

JShell

Command line or interactive Java Shell.

Java 9+:

$ jshell
| Welcome to JShell -- Version 21.0.4
| For an introduction type: /help intro

jshell>

See also Groovy which is one of my favourite languages and has a shell:

groovysh

JBang

https://www.jbang.dev/

https://github.com/jbangdev

Packages executable self-contained source-only Java programs.

Install using SDKman:

sdk install jbang

Create a source code CLI program:

jbang init -t cli hellocli.java

Reading the source code it shebangs jbang and annotates the class with some metadata for jbang.

The first run downloads the dependencies mentioned in the source code

$ ./hellocli.java --help
[jbang] Resolving dependencies...
[jbang] info.picocli:picocli:4.6.3
[jbang] Dependencies resolved
[jbang] Building jar for hellocli.java...
Usage: hellocli [-hV] <greeting>
hellocli made with jbang
<greeting> The greeting to print
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
$ ./hellocli.java JBANG!
Hello JBANG!

Automatic fetches any dependencies referenced in the source code using //DEPS group:artifact:version comments or @Grab annotations.

Even downloads a JDK if needed.

This makes portable Java scripting easier.

JBang CLI

jbang -c 'Java_code'

Example of JBang CLI using Faker library to output random names:

// DEPS com.github.javafaker.javafaker:1.0.2

import com.github.javafaker.Faker

Faker faker = new Faker()
cat > /tmp/faker.java <<EOF
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.github.javafaker:javafaker:1.0.2

import com.github.javafaker.Faker;
import java.util.stream.Stream;

public class faker {
public static void main(String[] args) {
Faker faker = new Faker();
Stream.generate(faker.name()::fullName)
.filter(s -> s.contains("Hari"))
.forEach(s -> System.out.println(s + " is Awesome"));
}
}
EOF
jbang /tmp/faker.java

See also Groovy which is one of my favourite languages and wish I had more excuses to code it in other than:

GraalJS

oracle/graaljs

JavaScript engine running on JVM via GraalVM.

ECMAScript-compliant runtime to execute JavaScript and Node.js applications on JVM with benefits of GraalVM stack including interoperability with Java.

Clojure

https://clojure.org/

Just a jar, no dependency like Scala predef.

java -jar my.jar

ProGuard

ProGuard Core

https://www.guardsquare.com/proguard

https://www.guardsquare.com/manual/home

https://playground.proguard.com/

Guardsquare/proguard-core

Shrinker, optimizer, and obfuscator for Java and Kotlin code.

ProGuard Assembler / Disassembler

GuardSquare/proguard-assembler

Kotlin Metadata Printer

GuardSquare/kotlin-metadata-printer

ProGuard iXGuard

https://www.guardsquare.com/ixguard

Obfuscates iOS code. See iXGuard page.

JVM Distributions

https://sdkman.io/jdks

These are the options you'll see when you install SDKman and sdk list java.

Temurin is the default open source distribution that SDKman uses.

Corretto

Amazon's OpenJDK distribution with long-term support and performance enhancements.

https://aws.amazon.com/corretto/

Gluon

Mobile-focused OpenJDK distribution optimized for JavaFX applications.

https://gluonhq.com/products/mobile/

GraalVM

High-performance JDK with ahead-of-time compilation and polyglot capabilities.

https://www.graalvm.org/

Java.net

Official OpenJDK reference builds provided by Oracle.

https://jdk.java.net/

JetBrains

Custom JDK distribution optimized for JetBrains IDEs.

JetBrains/JetBrainsRuntime

Liberica

Full OpenJDK distribution with JavaFX support from BellSoft.

https://bell-sw.com/liberica/

Mandrel

GraalVM-based JDK optimized for Quarkus applications.

graalvm/mandrel

Microsoft

Microsoft's OpenJDK distribution with enterprise support.

https://learn.microsoft.com/en-us/java/openjdk/

Oracle

Official Oracle JDK with commercial support and licensing requirements.

https://www.oracle.com/java/technologies/downloads/

SapMachine

SAP's OpenJDK distribution optimized for SAP workloads.

https://sap.github.io/SapMachine/

Semeru

IBM's OpenJDK distribution with Eclipse OpenJ9 for performance optimizations.

https://developer.ibm.com/languages/java/semeru-runtimes/

Temurin

Community-driven OpenJDK distribution maintained by Adoptium.

https://adoptium.net/

Tencent

Tencent's OpenJDK distribution optimized for cloud environments.

Tencent/TencentKona-8

Zulu

Azul's OpenJDK distribution with commercial support and JavaFX options.

https://www.azul.com/downloads/zulu/

Memes

Books That Made You Cry

Porting Your Language to the JVM

Imported Package Tariffs

Santa, Want Dragon

Balancing Dog

Ported from various private Knowledge Base pages 2010+