Skip to content

Latest commit

 

History

History
105 lines (70 loc) · 1.77 KB

java.md

File metadata and controls

105 lines (70 loc) · 1.77 KB

Java

NOT PORTED YET.

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.

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"

Clojure

https://clojure.org/

Just a jar, no dependency like Scala predef.

java -jar my.jar

Ported from various private Knowledge Base pages 2010+