Find out what classes are loaded by the JVM
-
Use JVM option
-verbose:classforjavacommand line[0.688s][info][class,load] ch.qos.logback.classic.Logger source: file:/mnt/c/Users/Takechiyo/.m2/repository/ch/qos/logback/logback-classic/1.2.10/logback-classic-1.2.10.jar -
Use Java
API-
Determine the file containing the class
var clazz = Logger.class; var resourceName = clazz.getSimpleName() + ".class"; System.out.println(clazz.getCanonicalName() + ": " + clazz.getResource(resourceName)); // ch.qos.logback.classic.Logger: jar:file:/C:/Users/Takechiyo/.m2/repository/ch/qos/logback/logback-classic/1.2.10/logback-classic-1.2.10.jar!/ch/qos/logback/classic/Logger.class -
Determine the classloader and file containing the class
private static void examineClass(Class<?> classObject) { var fullName = classObject.getName(); var resourceName = fullName.replaceAll("\\.", "/") + ".class"; try { var clazz = Class.forName(fullName); var loader = clazz.getClassLoader(); System.out.println("Class: " + clazz.getName()); System.out.println("Loader: " + loader); var url = ClassLoader.getSystemResource(resourceName); System.out.println("Loaded from: " + url); System.out.println("All locations: "); var e = ClassLoader.getSystemResources(resourceName); while (e.hasMoreElements()) { url = e.nextElement(); System.out.println(" " + url); } } catch (Exception e) { e.printStackTrace(); } } examineClass(ch.qos.logback.classic.Logger.class); /** Class: ch.qos.logback.classic.Logger Loader: jdk.internal.loader.ClassLoaders$AppClassLoader@77556fd Loaded from: jar:file:/C:/Users/Takechiyo/.m2/repository/ch/qos/logback/logback-classic/1.2.10/logback-classic-1.2.10.jar!/ch/qos/logback/classic/Logger.class All locations: jar:file:/C:/Users/Takechiyo/.m2/repository/ch/qos/logback/logback-classic/1.2.10/logback-classic-1.2.10.jar!/ch/qos/logback/classic/Logger.class */
-
Classloaders
Fundamental classloaders
- Primordial/Bootstrap classloader
- Loads the most fundamental Java library classes
- Part of JVM
- Extension/Platform classloader
- Typical name:
sun.misc.Launcher$ExtClassLoader - Security extension
- Typical name:
- Application/System classloader
- Typical name:
sun.misc.Launcher$AppClassLoader/jdk.internal.loader.ClassLoaders$AppClassLoader - Most widely used
- Loads classes and JAR files on the classpath
- Typical name:
The parent-delegation model
- Because class loading is always delegated first to the parent of the class loading hierarchy, the most trusted repository (the core API) is checked first, followed by the standard extensions, then the local files that are on the class path. Finally, classes that are located in any repository that your own class loader can access, are accessible. This system prevents code from less-trusted sources from replacing trusted core API classes by assuming the same name as part of the core API.
Notes
- You can load classes from a directory or JAR file that is not already on the classpath, by creating your own
URLClassLoaderinstance. This is commonly done to load plugins. - The second parameter in the call
Class.forName(className, true, loader)ensures that the static initialization of the class happens after loading. You definitely want that to happen. - Do NOT use the
ClassLoader.loadClassmethod. It does not run the static initializers. - The
URLClassLoaderloads classes from the file system. If you want to load a class from somewhere else, you need to write your own class loader by extendingjava.lang.ClassLoaderand implementingprotected Class<?> findClass(String name) throws ClassNotFoundException. - When loading classes dynamically from external sources like plugins, we should use the corresponding Classloader to load target classes to ensure the target URL of the class
Code snippets
Get Classpath Resources
ClassLoader.getSystemResources("")?.collect { URL classPath ->
def list = []
new File(classPath.toURI()).traverse(type: FileType.FILES) {
list << it.path
}
list
}private static List<String> getClassPathResources(String fileExtension) {
try {
List<Path> classPaths = EnumerationUtils.toList(ClassLoader.getSystemResources("")).stream().map(u -> {
try {
return Paths.get(u.toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
return classPaths.stream().flatMap(p -> {
try {
return Files.walk(p).filter(d -> Files.isRegularFile(d))
.filter(f -> Strings.isNullOrEmpty(fileExtension) || f.toString().endsWith(String.format(".%s", fileExtension)))
.map(i -> i.toAbsolutePath().toString());
} catch (IOException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException(e);
}
}Bytecode
Determine the version of Java class file
javap -v $class_file | grep versionBytecode versions matrix
| Java SE | Released | Major | Supported majors |
|---|---|---|---|
| 1.0.2 | May 1996 | 45 | 45 |
| 1.1 | February 1997 | 45 | 45 |
| 1.2 | December 1998 | 46 | 45 .. 46 |
| 1.3 | May 2000 | 47 | 45 .. 47 |
| 1.4 | February 2002 | 48 | 45 .. 48 |
| 5.0 | September 2004 | 49 | 45 .. 49 |
| 6 | December 2006 | 50 | 45 .. 50 |
| 7 | July 2011 | 51 | 45 .. 51 |
| 8 | March 2014 | 52 | 45 .. 52 |
| 9 | September 2017 | 53 | 45 .. 53 |
| 10 | March 2018 | 54 | 45 .. 54 |
| 11 | September 2018 | 55 | 45 .. 55 |
| 12 | March 2019 | 56 | 45 .. 56 |
| 13 | September 2019 | 57 | 45 .. 57 |
| 14 | March 2020 | 58 | 45 .. 58 |
| 15 | September 2020 | 59 | 45 .. 59 |
| 16 | March 2021 | 60 | 45 .. 60 |
| 17 | September 2021 | 61 | 45 .. 61 |
| 18 | March 2022 | 62 | 45 .. 62 |
| 19 | September 2022 | 63 | 45 .. 63 |
| 20 | March 2023 | 64 | 45 .. 64 |
| 21 | 65 | 45 .. 65 |
List of bytecode instructions
Wikipedia - List of Java bytecode instructions (opens in a new tab)
CLI
jar
List files included in a JAR file
-
jar tf $jar_file- The listed file path is the identifier you used to reference the file, and it can be used to extract or update the particular file.
e.g.
jar tf playground-spring-boot-cli-0.1-SNAPSHOT.jar | grep properties 90:BOOT-INF/classes/application.properties 95:META-INF/maven/cq-playground/playground-spring-boot-cli/pom.properties
Extract files from a JAR file
-
jar xvf $jar_fileExtract all files
-
jar xvf $jar_file [$file1, $file2...]Extract specified files, note the file name must contain path from within the archive, file name alone is not enough.
e.g.
jar xf playground-spring-boot-cli-0.1-SNAPSHOT.jar BOOT-INF/classes/application.properties
Note:
unzipcan also extract files from a JAR file.
Update a file from a JAR file
jar uf $jar_file [$file1, $file2...]javac
Usage: javac <options> <source files>
where possible options include:
@<filename> Read options and filenames from file
-Akey[=value] Options to pass to annotation processors
--add-modules <module>(,<module>)*
Root modules to resolve in addition to the initial modules,
or all modules on the module path if <module> is ALL-MODULE-PATH.
--boot-class-path <path>, -bootclasspath <path>
Override location of bootstrap class files
--class-path <path>, -classpath <path>, -cp <path>
Specify where to find user class files and annotation processors
-d <directory> Specify where to place generated class files
-deprecation
Output source locations where deprecated APIs are used
--enable-preview
Enable preview language features.
To be used in conjunction with either -source or --release.
-encoding <encoding> Specify character encoding used by source files
-endorseddirs <dirs> Override location of endorsed standards path
-extdirs <dirs> Override location of installed extensions
-g Generate all debugging info
-g:{lines,vars,source} Generate only some debugging info
-g:none Generate no debugging info
-h <directory>
Specify where to place generated native header files
--help, -help, -? Print this help message
--help-extra, -X Print help on extra options
-implicit:{none,class}
Specify whether to generate class files for implicitly referenced files
-J<flag> Pass <flag> directly to the runtime system
--limit-modules <module>(,<module>)*
Limit the universe of observable modules
--module <module>(,<module>)*, -m <module>(,<module>)*
Compile only the specified module(s), check timestamps
--module-path <path>, -p <path>
Specify where to find application modules
--module-source-path <module-source-path>
Specify where to find input source files for multiple modules
--module-version <version>
Specify version of modules that are being compiled
-nowarn Generate no warnings
-parameters
Generate metadata for reflection on method parameters
-proc:{none,only,full}
Control whether annotation processing and/or compilation is done.
-processor <class1>[,<class2>,<class3>...]
Names of the annotation processors to run;
bypasses default discovery process
--processor-module-path <path>
Specify a module path where to find annotation processors
--processor-path <path>, -processorpath <path>
Specify where to find annotation processors
-profile <profile>
Check that API used is available in the specified profile.
This option is deprecated and may be removed in a future release.
--release <release>
Compile for the specified Java SE release.
Supported releases:
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
-s <directory> Specify where to place generated source files
--source <release>, -source <release>
Provide source compatibility with the specified Java SE release.
Supported releases:
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
--source-path <path>, -sourcepath <path>
Specify where to find input source files
--system <jdk>|none Override location of system modules
--target <release>, -target <release>
Generate class files suitable for the specified Java SE release.
Supported releases:
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
--upgrade-module-path <path>
Override location of upgradeable modules
-verbose Output messages about what the compiler is doing
--version, -version Version information
-Werror Terminate compilation if warnings occurShow all lint keys
javac --help-lintThe supported keys for -Xlint are:
all Enable all warnings
auxiliaryclass Warn about an auxiliary class that is hidden in a source file, and is used from other files.
cast Warn about use of unnecessary casts.
classfile Warn about issues related to classfile contents.
deprecation Warn about use of deprecated items.
dep-ann Warn about items marked as deprecated in JavaDoc but not using the @Deprecated annotation.
divzero Warn about division by constant integer 0.
empty Warn about empty statement after if.
exports Warn about issues regarding module exports.
fallthrough Warn about falling through from one case of a switch statement to the next.
finally Warn about finally clauses that do not terminate normally.
lossy-conversions Warn about possible lossy conversions in compound assignment.
missing-explicit-ctor Warn about missing explicit constructors in public and protected classes in exported packages.
module Warn about module system related issues.
opens Warn about issues regarding module opens.
options Warn about issues relating to use of command line options.
output-file-clash Warn when an output file is overwritten during compilation. This can occur, for example,
on case-insensitive filesystems. Covers class files, native header files, and source files.
overloads Warn about issues regarding method overloads.
overrides Warn about issues regarding method overrides.
path Warn about invalid path elements on the command line.
processing Warn about issues regarding annotation processing.
rawtypes Warn about use of raw types.
removal Warn about use of API that has been marked for removal.
requires-automatic Warn about use of automatic modules in the requires clauses.
requires-transitive-automatic Warn about automatic modules in requires transitive.
serial Warn about Serializable classes that do not have a serialVersionUID field.
Also warn about other suspect declarations in Serializable and Externalizable classes and interfaces.
static Warn about accessing a static member using an instance.
strictfp Warn about unnecessary use of the strictfp modifier.
synchronization Warn about synchronization attempts on instances of value-based classes.
text-blocks Warn about inconsistent white space characters in text block indentation.
this-escape Warn when a constructor invokes a method that could be overriden in an external subclass.
Such a method would execute before the subclass constructor completes its initialization.
try Warn about issues relating to use of try blocks (i.e. try-with-resources).
unchecked Warn about unchecked operations.
varargs Warn about potentially unsafe vararg methods.
preview Warn about use of preview language features.
none Disable all warningsCan be turned on with javac -Xlint:$key
java
Usage: java [options] <mainclass> [args...]
(to execute a class)
or java [options] -jar <jarfile> [args...]
(to execute a jar file)
or java [options] -m <module>[/<mainclass>] [args...]
java [options] --module <module>[/<mainclass>] [args...]
(to execute the main class in a module)
or java [options] <sourcefile> [args]
(to execute a single source-file program)
Arguments following the main class, source file, -jar <jarfile>,
-m or --module <module>/<mainclass> are passed as the arguments to
main class.
where options include:
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
--class-path <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-p <module path>
--module-path <module path>...
A : separated list of elements, each element is a file path
to a module or a directory containing modules. Each module is either
a modular JAR or an exploded-module directory.
--upgrade-module-path <module path>...
A : separated list of elements, each element is a file path
to a module or a directory containing modules to replace
upgradeable modules in the runtime image. Each module is either
a modular JAR or an exploded-module directory.
--add-modules <module name>[,<module name>...]
root modules to resolve in addition to the initial module.
<module name> can also be ALL-DEFAULT, ALL-SYSTEM,
ALL-MODULE-PATH.
--enable-native-access <module name>[,<module name>...]
modules that are permitted to perform restricted native operations.
<module name> can also be ALL-UNNAMED.
--list-modules
list observable modules and exit
-d <module name>
--describe-module <module name>
describe a module and exit
--dry-run create VM and load main class but do not execute main method.
The --dry-run option may be useful for validating the
command-line options such as the module system configuration.
--validate-modules
validate all modules and exit
The --validate-modules option may be useful for finding
conflicts and other errors with modules on the module path.
-D<name>=<value>
set a system property
-verbose:[class|module|gc|jni]
enable verbose output for the given subsystem
-version print product version to the error stream and exit
--version print product version to the output stream and exit
-showversion print product version to the error stream and continue
--show-version
print product version to the output stream and continue
--show-module-resolution
show module resolution output during startup
-? -h -help
print this help message to the error stream
--help print this help message to the output stream
-X print help on extra options to the error stream
--help-extra print help on extra options to the output stream
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:jdwp
see also -agentlib:jdwp=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
HiDPI scaled images are automatically supported and used
if available. The unscaled image filename, e.g. image.ext,
should always be passed as the argument to the -splash option.
The most appropriate scaled image provided will be picked up
automatically.
See the SplashScreen API documentation for more information
@argument files
one or more argument files containing options
--disable-@files
prevent further argument file expansion
--enable-preview
allow classes to depend on preview features of this release
To specify an argument for a long option, you can use --<name>=<value> or
--<name> <value>.java - command reference
Oracle Help Center - Java SE 21 - Tools Reference - The java command (opens in a new tab)
java - VM Options Explorer
VM Options Explorer (opens in a new tab)
java - shows non-standard options
java -Xjava - specify system properties
java -D$property_name=$property_value $class_nameUse jcmd $JVM_PID VM.system_properties to verify if a property is effective
java - display system property settings
java -XshowSettings:propertiesOutput:
Property settings:
file.encoding = UTF-8
file.separator = /
java.class.path =
java.class.version = 65.0
java.home = /home/takechiyo/.sdkman/candidates/java/21.0.2-graalce
java.io.tmpdir = /tmp
java.library.path = /usr/java/packages/lib
/usr/lib64
/lib64
/lib
/usr/lib
java.runtime.name = OpenJDK Runtime Environment
java.runtime.version = 21.0.2+13-jvmci-23.1-b30
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 21
java.vendor = GraalVM Community
java.vendor.url = https://www.graalvm.org/
java.vendor.url.bug = https://github.com/oracle/graal/issues
java.vendor.version = GraalVM CE 21.0.2+13.1
java.version = 21.0.2
java.version.date = 2024-01-16
java.vm.compressedOopsMode = Zero based
java.vm.info = mixed mode, sharing
java.vm.name = OpenJDK 64-Bit Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 21
java.vm.vendor = GraalVM Community
java.vm.version = 21.0.2+13-jvmci-23.1-b30
jdk.debug = release
jdk.internal.vm.ci.enabled = true
line.separator = \n
native.encoding = UTF-8
os.arch = amd64
os.name = Linux
os.version = 6.6.87.2-microsoft-standard-WSL2
path.separator = :
stderr.encoding = UTF-8
stdout.encoding = UTF-8
sun.arch.data.model = 64
sun.boot.library.path = /home/takechiyo/.sdkman/candidates/java/21.0.2-graalce/lib
sun.cpu.endian = little
sun.io.unicode.encoding = UnicodeLittle
sun.java.launcher = SUN_STANDARD
sun.jnu.encoding = UTF-8
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
user.country = US
user.dir = /mnt/c/Users/Takechiyo/workspace
user.home = /home/takechiyo
user.language = en
user.name = takechiyojava - use @ prefix to reference files containing arguments
Use the @ prefix to identify an argument file that contains java options and class names.
e.g.
java @path1/options @path2/classesjava - debug SSL/TLS Connections
-
Use system property
javax.net.debug=ssl, for options check reference below.# The current options are: all: Turn on all debugging ssl: Turn on SSL debugging # The following can be used with the ssl option to select what type of debug information to print: defaultctx: Print default SSL initialization handshake: Print each handshake message keygen: Print key generation data keymanager: Print key manager tracing pluggability: Print pluggability tracing record: Enable per-record tracing respmgr: Print status response manager tracing session: Print session activity sessioncache: Print session cache tracing sslctx: Print SSLContext tracing trustmanager: Print trust manager tracing # Messages generated from the handshake option can be widened with these options: data: Hex dump of each handshake message verbose: Verbose handshake message printing # Messages generated from the record option can be widened with these options: plaintext: Hex dump of record plaintext packet: Print raw SSL/TLS packets -
Resources
java - view security properties, security providers, and TLS-related settings
java -XshowSettings:securityOutput:
VM settings:
Max. Heap Size (Estimated): 3.90G
Using VM: OpenJDK 64-Bit Server VM
Property settings:
file.encoding = UTF-8
file.separator = /
java.class.path =
java.class.version = 65.0
java.home = /home/takechiyo/.sdkman/candidates/java/21.0.2-graalce
java.io.tmpdir = /tmp
java.library.path = /usr/java/packages/lib
/usr/lib64
/lib64
/lib
/usr/lib
java.runtime.name = OpenJDK Runtime Environment
java.runtime.version = 21.0.2+13-jvmci-23.1-b30
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 21
java.vendor = GraalVM Community
java.vendor.url = https://www.graalvm.org/
java.vendor.url.bug = https://github.com/oracle/graal/issues
java.vendor.version = GraalVM CE 21.0.2+13.1
java.version = 21.0.2
java.version.date = 2024-01-16
java.vm.compressedOopsMode = Zero based
java.vm.info = mixed mode, sharing
java.vm.name = OpenJDK 64-Bit Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 21
java.vm.vendor = GraalVM Community
java.vm.version = 21.0.2+13-jvmci-23.1-b30
jdk.debug = release
jdk.internal.vm.ci.enabled = true
line.separator = \n
native.encoding = UTF-8
os.arch = amd64
os.name = Linux
os.version = 6.6.87.2-microsoft-standard-WSL2
path.separator = :
stderr.encoding = UTF-8
stdout.encoding = UTF-8
sun.arch.data.model = 64
sun.boot.library.path = /home/takechiyo/.sdkman/candidates/java/21.0.2-graalce/lib
sun.cpu.endian = little
sun.io.unicode.encoding = UnicodeLittle
sun.java.launcher = SUN_STANDARD
sun.jnu.encoding = UTF-8
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
user.country = US
user.dir = /mnt/c/Users/Takechiyo/workspace
user.home = /home/takechiyo
user.language = en
user.name = takechiyo
Locale settings:
default locale = English (United States)
default display locale = English (United States)
default format locale = English (United States)
tzdata version = 2023c
available locales = , af, af_NA, af_ZA, af_ZA_#Latn, agq, agq_CM, agq_CM_#Latn,
ak, ak_GH, ak_GH_#Latn, am, am_ET, am_ET_#Ethi, ann, ann_NG,
ann_NG_#Latn, ar, ar_001, ar_AE, ar_BH, ar_DJ, ar_DZ, ar_EG,
ar_EG_#Arab, ar_EH, ar_ER, ar_IL, ar_IQ, ar_JO, ar_KM, ar_KW,
ar_LB, ar_LY, ar_MA, ar_MR, ar_OM, ar_PS, ar_QA, ar_SA,
ar_SD, ar_SO, ar_SS, ar_SY, ar_TD, ar_TN, ar_YE, as,
as_IN, as_IN_#Beng, asa, asa_TZ, asa_TZ_#Latn, ast, ast_ES, ast_ES_#Latn,
az, az_AZ, az_AZ_#Cyrl, az_AZ_#Latn, az__#Cyrl, az__#Latn, bas, bas_CM,
bas_CM_#Latn, be, be_BY, be_BY_#Cyrl, be__TARASK, bem, bem_ZM, bem_ZM_#Latn,
bez, bez_TZ, bez_TZ_#Latn, bg, bg_BG, bg_BG_#Cyrl, bgc, bgc_IN,
bgc_IN_#Deva, bho, bho_IN, bho_IN_#Deva, bm, bm_ML, bm_ML_#Latn, bn,
bn_BD, bn_BD_#Beng, bn_IN, bo, bo_CN, bo_CN_#Tibt, bo_IN, br,
br_FR, br_FR_#Latn, brx, brx_IN, brx_IN_#Deva, bs, bs_BA, bs_BA_#Cyrl,
bs_BA_#Latn, bs__#Cyrl, bs__#Latn, ca, ca_AD, ca_ES, ca_ES_#Latn, ca_ES_VALENCIA,
ca_FR, ca_IT, ccp, ccp_BD, ccp_BD_#Cakm, ccp_IN, ce, ce_RU,
ce_RU_#Cyrl, ceb, ceb_PH, ceb_PH_#Latn, cgg, cgg_UG, cgg_UG_#Latn, chr,
chr_US, chr_US_#Cher, ckb, ckb_IQ, ckb_IQ_#Arab, ckb_IR, cs, cs_CZ,
cs_CZ_#Latn, cv, cv_RU, cv_RU_#Cyrl, cy, cy_GB, cy_GB_#Latn, da,
da_DK, da_DK_#Latn, da_GL, dav, dav_KE, dav_KE_#Latn, de, de_AT,
de_BE, de_CH, de_DE, de_DE_#Latn, de_IT, de_LI, de_LU, dje,
dje_NE, dje_NE_#Latn, doi, doi_IN, doi_IN_#Deva, dsb, dsb_DE, dsb_DE_#Latn,
dua, dua_CM, dua_CM_#Latn, dyo, dyo_SN, dyo_SN_#Latn, dz, dz_BT,
dz_BT_#Tibt, ebu, ebu_KE, ebu_KE_#Latn, ee, ee_GH, ee_GH_#Latn, ee_TG,
el, el_CY, el_GR, el_GR_#Grek, el__POLYTON, en, en_001, en_150,
en_AE, en_AG, en_AI, en_AS, en_AT, en_AU, en_BB, en_BE,
en_BI, en_BM, en_BS, en_BW, en_BZ, en_CA, en_CC, en_CH,
en_CK, en_CM, en_CX, en_CY, en_DE, en_DG, en_DK, en_DM,
en_ER, en_FI, en_FJ, en_FK, en_FM, en_GB, en_GD, en_GG,
en_GH, en_GI, en_GM, en_GU, en_GY, en_HK, en_IE, en_IL,
en_IM, en_IN, en_IO, en_JE, en_JM, en_KE, en_KI, en_KN,
en_KY, en_LC, en_LR, en_LS, en_MG, en_MH, en_MO, en_MP,
en_MS, en_MT, en_MU, en_MV, en_MW, en_MY, en_NA, en_NF,
en_NG, en_NL, en_NR, en_NU, en_NZ, en_PG, en_PH, en_PK,
en_PN, en_PR, en_PW, en_RW, en_SB, en_SC, en_SD, en_SE,
en_SG, en_SH, en_SI, en_SL, en_SS, en_SX, en_SZ, en_TC,
en_TK, en_TO, en_TT, en_TV, en_TZ, en_UG, en_UM, en_US,
en_US_#Latn, en_US_POSIX, en_VC, en_VG, en_VI, en_VU, en_WS, en_ZA,
en_ZM, en_ZW, eo, eo_001, eo_001_#Latn, es, es_419, es_AR,
es_BO, es_BR, es_BZ, es_CL, es_CO, es_CR, es_CU, es_DO,
es_EA, es_EC, es_ES, es_ES_#Latn, es_GQ, es_GT, es_HN, es_IC,
es_MX, es_NI, es_PA, es_PE, es_PH, es_PR, es_PY, es_SV,
es_US, es_UY, es_VE, et, et_EE, et_EE_#Latn, eu, eu_ES,
eu_ES_#Latn, ewo, ewo_CM, ewo_CM_#Latn, fa, fa_AF, fa_IR, fa_IR_#Arab,
ff, ff_BF_#Adlm, ff_BF_#Latn, ff_CM_#Adlm, ff_CM_#Latn, ff_GH_#Adlm, ff_GH_#Latn, ff_GM_#Adlm,
ff_GM_#Latn, ff_GN, ff_GN_#Adlm, ff_GN_#Latn, ff_GW_#Adlm, ff_GW_#Latn, ff_LR_#Adlm, ff_LR_#Latn,
ff_MR_#Adlm, ff_MR_#Latn, ff_NE_#Adlm, ff_NE_#Latn, ff_NG_#Adlm, ff_NG_#Latn, ff_SL_#Adlm, ff_SL_#Latn,
ff_SN, ff_SN_#Adlm, ff_SN_#Latn, ff__#Adlm, ff__#Latn, fi, fi_FI, fi_FI_#Latn,
fil, fil_PH, fil_PH_#Latn, fo, fo_DK, fo_FO, fo_FO_#Latn, fr,
fr_BE, fr_BF, fr_BI, fr_BJ, fr_BL, fr_CA, fr_CD, fr_CF,
fr_CG, fr_CH, fr_CI, fr_CM, fr_DJ, fr_DZ, fr_FR, fr_FR_#Latn,
fr_GA, fr_GF, fr_GN, fr_GP, fr_GQ, fr_HT, fr_KM, fr_LU,
fr_MA, fr_MC, fr_MF, fr_MG, fr_ML, fr_MQ, fr_MR, fr_MU,
fr_NC, fr_NE, fr_PF, fr_PM, fr_RE, fr_RW, fr_SC, fr_SN,
fr_SY, fr_TD, fr_TG, fr_TN, fr_VU, fr_WF, fr_YT, frr,
frr_DE, frr_DE_#Latn, fur, fur_IT, fur_IT_#Latn, fy, fy_NL, fy_NL_#Latn,
ga, ga_GB, ga_IE, ga_IE_#Latn, gd, gd_GB, gd_GB_#Latn, gl,
gl_ES, gl_ES_#Latn, gsw, gsw_CH, gsw_CH_#Latn, gsw_FR, gsw_LI, gu,
gu_IN, gu_IN_#Gujr, guz, guz_KE, guz_KE_#Latn, gv, gv_IM, gv_IM_#Latn,
ha, ha_GH, ha_NE, ha_NG, ha_NG_#Latn, haw, haw_US, haw_US_#Latn,
he, he_IL, he_IL_#Hebr, hi, hi_IN, hi_IN_#Deva, hi_IN_#Latn, hi__#Latn,
hr, hr_BA, hr_HR, hr_HR_#Latn, hsb, hsb_DE, hsb_DE_#Latn, hu,
hu_HU, hu_HU_#Latn, hy, hy_AM, hy_AM_#Armn, ia, ia_001, ia_001_#Latn,
id, id_ID, id_ID_#Latn, ig, ig_NG, ig_NG_#Latn, ii, ii_CN,
ii_CN_#Yiii, is, is_IS, is_IS_#Latn, it, it_CH, it_IT, it_IT_#Latn,
it_SM, it_VA, ja, ja_JP, ja_JP_#Jpan, ja_JP_JP_#u-ca-japanese, jgo, jgo_CM,
jgo_CM_#Latn, jmc, jmc_TZ, jmc_TZ_#Latn, jv, jv_ID, jv_ID_#Latn, ka,
ka_GE, ka_GE_#Geor, kab, kab_DZ, kab_DZ_#Latn, kam, kam_KE, kam_KE_#Latn,
kde, kde_TZ, kde_TZ_#Latn, kea, kea_CV, kea_CV_#Latn, kgp, kgp_BR,
kgp_BR_#Latn, khq, khq_ML, khq_ML_#Latn, ki, ki_KE, ki_KE_#Latn, kk,
kk_KZ, kk_KZ_#Cyrl, kkj, kkj_CM, kkj_CM_#Latn, kl, kl_GL, kl_GL_#Latn,
kln, kln_KE, kln_KE_#Latn, km, km_KH, km_KH_#Khmr, kn, kn_IN,
kn_IN_#Knda, ko, ko_KP, ko_KR, ko_KR_#Kore, kok, kok_IN, kok_IN_#Deva,
ks, ks_IN, ks_IN_#Arab, ks_IN_#Deva, ks__#Arab, ks__#Deva, ksb, ksb_TZ,
ksb_TZ_#Latn, ksf, ksf_CM, ksf_CM_#Latn, ksh, ksh_DE, ksh_DE_#Latn, ku,
ku_TR, ku_TR_#Latn, kw, kw_GB, kw_GB_#Latn, ky, ky_KG, ky_KG_#Cyrl,
lag, lag_TZ, lag_TZ_#Latn, lb, lb_LU, lb_LU_#Latn, lg, lg_UG,
lg_UG_#Latn, lkt, lkt_US, lkt_US_#Latn, ln, ln_AO, ln_CD, ln_CD_#Latn,
ln_CF, ln_CG, lo, lo_LA, lo_LA_#Laoo, lrc, lrc_IQ, lrc_IR,
lrc_IR_#Arab, lt, lt_LT, lt_LT_#Latn, lu, lu_CD, lu_CD_#Latn, luo,
luo_KE, luo_KE_#Latn, luy, luy_KE, luy_KE_#Latn, lv, lv_LV, lv_LV_#Latn,
mai, mai_IN, mai_IN_#Deva, mas, mas_KE, mas_KE_#Latn, mas_TZ, mdf,
mdf_RU, mdf_RU_#Cyrl, mer, mer_KE, mer_KE_#Latn, mfe, mfe_MU, mfe_MU_#Latn,
mg, mg_MG, mg_MG_#Latn, mgh, mgh_MZ, mgh_MZ_#Latn, mgo, mgo_CM,
mgo_CM_#Latn, mi, mi_NZ, mi_NZ_#Latn, mk, mk_MK, mk_MK_#Cyrl, ml,
ml_IN, ml_IN_#Mlym, mn, mn_MN, mn_MN_#Cyrl, mni, mni_IN, mni_IN_#Beng,
mni__#Beng, mr, mr_IN, mr_IN_#Deva, ms, ms_BN, ms_ID, ms_MY,
ms_MY_#Latn, ms_SG, mt, mt_MT, mt_MT_#Latn, mua, mua_CM, mua_CM_#Latn,
my, my_MM, my_MM_#Mymr, mzn, mzn_IR, mzn_IR_#Arab, naq, naq_NA,
naq_NA_#Latn, nb, nb_NO, nb_NO_#Latn, nb_SJ, nd, nd_ZW, nd_ZW_#Latn,
nds, nds_DE, nds_DE_#Latn, nds_NL, ne, ne_IN, ne_NP, ne_NP_#Deva,
nl, nl_AW, nl_BE, nl_BQ, nl_CW, nl_NL, nl_NL_#Latn, nl_SR,
nl_SX, nmg, nmg_CM, nmg_CM_#Latn, nn, nn_NO, nn_NO_#Latn, nnh,
nnh_CM, nnh_CM_#Latn, no, no_NO, no_NO_#Latn, no_NO_NY, nus, nus_SS,
nus_SS_#Latn, nyn, nyn_UG, nyn_UG_#Latn, oc, oc_ES, oc_FR, oc_FR_#Latn,
om, om_ET, om_ET_#Latn, om_KE, or, or_IN, or_IN_#Orya, os,
os_GE, os_GE_#Cyrl, os_RU, pa, pa_IN, pa_IN_#Guru, pa_PK, pa_PK_#Arab,
pa__#Arab, pa__#Guru, pcm, pcm_NG, pcm_NG_#Latn, pis, pis_SB, pis_SB_#Latn,
pl, pl_PL, pl_PL_#Latn, ps, ps_AF, ps_AF_#Arab, ps_PK, pt,
pt_AO, pt_BR, pt_BR_#Latn, pt_CH, pt_CV, pt_GQ, pt_GW, pt_LU,
pt_MO, pt_MZ, pt_PT, pt_ST, pt_TL, qu, qu_BO, qu_EC,
qu_PE, qu_PE_#Latn, raj, raj_IN, raj_IN_#Deva, rm, rm_CH, rm_CH_#Latn,
rn, rn_BI, rn_BI_#Latn, ro, ro_MD, ro_RO, ro_RO_#Latn, rof,
rof_TZ, rof_TZ_#Latn, ru, ru_BY, ru_KG, ru_KZ, ru_MD, ru_RU,
ru_RU_#Cyrl, ru_UA, rw, rw_RW, rw_RW_#Latn, rwk, rwk_TZ, rwk_TZ_#Latn,
sa, sa_IN, sa_IN_#Deva, sah, sah_RU, sah_RU_#Cyrl, saq, saq_KE,
saq_KE_#Latn, sat, sat_IN, sat_IN_#Olck, sat__#Olck, sbp, sbp_TZ, sbp_TZ_#Latn,
sc, sc_IT, sc_IT_#Latn, sd, sd_IN, sd_IN_#Deva, sd_PK, sd_PK_#Arab,
sd__#Arab, sd__#Deva, se, se_FI, se_NO, se_NO_#Latn, se_SE, seh,
seh_MZ, seh_MZ_#Latn, ses, ses_ML, ses_ML_#Latn, sg, sg_CF, sg_CF_#Latn,
shi, shi_MA, shi_MA_#Latn, shi_MA_#Tfng, shi__#Latn, shi__#Tfng, si, si_LK,
si_LK_#Sinh, sk, sk_SK, sk_SK_#Latn, sl, sl_SI, sl_SI_#Latn, smn,
smn_FI, smn_FI_#Latn, sms, sms_FI, sms_FI_#Latn, sn, sn_ZW, sn_ZW_#Latn,
so, so_DJ, so_ET, so_KE, so_SO, so_SO_#Latn, sq, sq_AL,
sq_AL_#Latn, sq_MK, sq_XK, sr, sr_BA, sr_BA_#Cyrl, sr_BA_#Latn, sr_CS,
sr_ME, sr_ME_#Cyrl, sr_ME_#Latn, sr_RS, sr_RS_#Cyrl, sr_RS_#Latn, sr_XK_#Cyrl, sr_XK_#Latn,
sr__#Cyrl, sr__#Latn, su, su_ID, su_ID_#Latn, su__#Latn, sv, sv_AX,
sv_FI, sv_SE, sv_SE_#Latn, sw, sw_CD, sw_KE, sw_TZ, sw_TZ_#Latn,
sw_UG, ta, ta_IN, ta_IN_#Taml, ta_LK, ta_MY, ta_SG, te,
te_IN, te_IN_#Telu, teo, teo_KE, teo_UG, teo_UG_#Latn, tg, tg_TJ,
tg_TJ_#Cyrl, th, th_TH, th_TH_#Thai, th_TH_TH_#u-nu-thai, ti, ti_ER, ti_ET,
ti_ET_#Ethi, tk, tk_TM, tk_TM_#Latn, to, to_TO, to_TO_#Latn, tok,
tok_001, tok_001_#Latn, tr, tr_CY, tr_TR, tr_TR_#Latn, tt, tt_RU,
tt_RU_#Cyrl, twq, twq_NE, twq_NE_#Latn, tzm, tzm_MA, tzm_MA_#Latn, ug,
ug_CN, ug_CN_#Arab, uk, uk_UA, uk_UA_#Cyrl, ur, ur_IN, ur_PK,
ur_PK_#Arab, uz, uz_AF, uz_AF_#Arab, uz_UZ, uz_UZ_#Cyrl, uz_UZ_#Latn, uz__#Arab,
uz__#Cyrl, uz__#Latn, vai, vai_LR, vai_LR_#Latn, vai_LR_#Vaii, vai__#Latn, vai__#Vaii,
vi, vi_VN, vi_VN_#Latn, vun, vun_TZ, vun_TZ_#Latn, wae, wae_CH,
wae_CH_#Latn, wo, wo_SN, wo_SN_#Latn, xh, xh_ZA, xh_ZA_#Latn, xog,
xog_UG, xog_UG_#Latn, yav, yav_CM, yav_CM_#Latn, yi, yi_001, yi_001_#Hebr,
yo, yo_BJ, yo_NG, yo_NG_#Latn, yrl, yrl_BR, yrl_BR_#Latn, yrl_CO,
yrl_VE, yue, yue_CN, yue_CN_#Hans, yue_HK, yue_HK_#Hant, yue__#Hans, yue__#Hant,
zgh, zgh_MA, zgh_MA_#Tfng, zh, zh_CN, zh_CN_#Hans, zh_HK, zh_HK_#Hans,
zh_HK_#Hant, zh_MO, zh_MO_#Hans, zh_MO_#Hant, zh_SG, zh_SG_#Hans, zh_TW, zh_TW_#Hant,
zh__#Hans, zh__#Hant, zu, zu_ZA, zu_ZA_#Latn
Operating System Metrics:
Provider: cgroupv2
Effective CPU Count: 16
CPU Period: -1
CPU Quota: -1
CPU Shares: -1
List of Processors: N/A
List of Effective Processors, 16 total:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
List of Memory Nodes: N/A
List of Available Memory Nodes, 1 total:
0
Memory Limit: Unlimited
Memory Soft Limit: Unlimited
Memory & Swap Limit: Unlimited
Maximum Processes Limit: Unlimitedjava - list security debugging options
java -Djava.security.debug=helpjava - apply additional JVM options via JDK_JAVA_OPTIONS and JAVA_TOOL_OPTIONS
JDK_JAVA_OPTIONS
- Only works for
Java 9+and thejavaCLI
JAVA_TOOL_OPTIONS
- In addition to
java, also works for other Java tools such asjarandjavac
# Set environment variable
export JDK_JAVA_OPTIONS="-Dspring.profiles.active=dev"
# Run JVM process
mvn spring-boot:run
# A message will display as confirmation
NOTE: Picked up JDK_JAVA_OPTIONS: -Dspring.profiles.active=devCaveat: JAVA_OPTS is not standard and not guaranteed to work.
-
Resource
- Oracle Help Center - Java SE 17 - Tools Reference - The java command - Using the JDK_JAVA_OPTIONS Launcher Environment Variable (opens in a new tab)
- Oracle - Java SE 21 - Troubleshooting Guide - Appendices - C Environment Variables and System Properties - JAVA_TOOL_OPTIONS (opens in a new tab)
- Stack Overflow - What is the difference between JDK_JAVA_OPTIONS and JAVA_TOOL_OPTIONS when using Java 11? (opens in a new tab)
JVM Options - GC
-
-XX:+DisableExplicitGC, causes the VM to ignore calls toSystem.gc(). -
Logging
-
JDK 8 and earlier
- Print GC log
-Xloggc:/opt/logs/gc-%t.log-XX:+PrintGCDetails-XX:+PrintGCTimeStamps-XX:+PrintGCCause-XX:+PrintTenuringDistribution-XX:+UseGCLogFileRotation-XX:NumberOfGCLogFiles=10-XX:GCLogFileSize=5M
- Print GC log
-
JDK 9+
-
Resources
-
JVM Options - Logging
JVM Options - Memory Settings
-
Heap
-
-Xmsis equivalent to-XX:InitialHeapSize. -
-Xmxis equivalent to-XX:MaxHeapSize. -
-Xmxshould be between 80% and 100% of the machine's physical memory. If you set-Xmxtoo small, the application server may fail with anOutOfMemoryerror. If you set-Xmxtoo large, the memory's footprint is larger and you run the risk of Java's heap being swapped out, causing other performance problems. -
-Xmsshould be approximately half of the-Xmxsetting. If you have historical data about your application server's stable memory-usage point, then set-Xmsto be around that value.
-
-
Metaspace (formely PermGen)
-
-XX:MaxMetaspaceSizeis the maximum amount of native memory that can be allocated for class metadata. The default value depends on the platform. -
-XX:MetaspaceSizeis the initial amount of native memory that can be allocated for class metadata. The default size of is platform-dependent and rangesfrom 12 MB to about 20 MB. -
-XX:MaxMetaspaceFreeRatiois the maximum percentage of class metadata free space to class metadata used space after a garbage collection. The default value is70. -
-XX:MinMetaspaceFreeRatiois the minimum percentage of class metadata free space to class metadata used space after a garbage collection. The default value is40. -
If you observe classes being unloaded during full garbage collections, you should use
-XX:PermSizeand-XX:MaxPermSizecommand line options to size the permanent generation space. To avoid full garbage collections that may expand or shrink the committed size of the permanent generation space, set-XX:PermSizeand-XX:MaxPermSizeto the same value. -
Resources
-
JVM Options - Compiler (JIT)
-XX:+PrintCompilationprints a message to the console when a method is compiled.-XX:+PrintCompilation2prints a message to the console when a method is compiled, and includes the time it took to compile the method.
JVM Options - Performance - based on JMC Automated Analysis Results
-
Java Application
-
Memory
-
Free Physical Memory
Having little free memorymay lead toswapping, which is very expensive. To avoid this, eitherdecrease the memory usageorincrease the amount of available memory.
-
-
Exceptions
-
Thrown Errors
Investigate the thrown errors to see if they can be avoided. Errors indicate that something went wrong with the code execution and should never be used for flow control.
-
-
-
JVM Internals
-
Stackdepth Setting
Some stack traces were truncated in this recording. If more detailed traces are required, increase the
-XX:FlightRecorderOptions=stackdepth=<value>value. -
GC Configuration
-
Compressed Oops
Not using
Compressed Ordinary Object Pointerswhen theheap sizeisbelow 32 GBwastes memory and will lead to unnecessary cache pressure. Use the JVM argument-XX:+UseCompressedOopsto enable this feature.Refer to OpenJDK Wiki - CompressedOops (opens in a new tab) for details.
-
-
-
Environment
-
Processes
-
Competing Processes
If this is a server environment, it may be good to only run other critical processes on that machine.
-
-
JVM Options - Resources
jps
jps - Get arguments of a running JVM process
-
JDK - jps (opens in a new tab)
jps -lvm
jps - List all local JVM processes with VM options
jps -lvmOutput (example):
2589 cq.playground.spring.microservice.rest.MainApplication --spring.profiles.active=dev,logging --logging.level.web=debug -XX:ThreadPriorityPolicy=1 -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCIProduct -XX:-UnlockExperimentalVMOptions -javaagent:/mnt/c/Users/Takechiyo/workspace/gitlab/spring-microservice/deployment/opentelemetry/opentelemetry-javaagent.jar -XX:TieredStopAtLevel=1 -Duser.dir=/mnt/c/Users/Takechiyo/workspace/gitlab/spring-microservice -XX:+UseZGC -XX:+ZGenerational -XX:InitialHeapSize=2g -XX:MaxHeapSize=2g -Xlog:gc*=info,gc+heap=debug,gc+ref*=debug,gc+ergo*=trace,gc+age*=trace:file=/mnt/c/Users/Takechiyo/workspace/gitlab/spring-microservice/target/gc-%t.log:utctime,pid,level,tags:filecount=2,filesize=100m -XX:StartFlightRecording=settings=default,filename=/mnt/c/Users/Takechiyo/workspace/gitlab/spring-microservice/target/spring-microservice.jfr,dumponexit=true,maxsize=100M -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=/mnt/c/Users/Takechiyo/workspace/gitlab/spring-microservice/target/jvm.log -XX:ErrorFile=/mnt/c/Users/Takechiyo/workspace/gitlab/spring-microservice/target/hs_err_%p.log -XX:+Disabljcmd
GC.class_statscommand requires-XX:+UnlockDiagnosticVMOptions
Usage: jcmd <pid | main class> <command ...|PerfCounter.print|-f file>
or: jcmd -l
or: jcmd -h
command must be a valid jcmd command for the selected jvm.
Use the command "help" to see which commands are available.
If the pid is 0, commands will be sent to all Java processes.
The main class argument will be used to match (either partially
or fully) the class used to start Java.
If no options are given, lists Java processes (same as -l).
PerfCounter.print display the counters exposed by this process
-f read and execute commands from the file
-l list JVM processes on the local machine
-? -h --help print this help message-
Comes with JDK 7+
-
Reference: Oracle Help Center - Java SE 25 - Tools Reference - jcmd Utility (opens in a new tab)
jcmd - List all local JVM processes
jcmd / jcmd -l# e.g.
$ jcmd
3157 org.gradle.launcher.GradleMain bootRun
2710 org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.5
5145 jdk.jcmd/sun.tools.jcmd.JCmd
3390 cq.playground.spring.poc.kafka.nonreactive.MainAppjcmd - List all diagnostic commands for a specific process
jcmd $PID [help]If PID is 0, the command is sent to all JVM processes
# e.g.
$ jcmd 3390
3390:
The following commands are available:
Compiler.CodeHeap_Analytics
Compiler.codecache
Compiler.codelist
Compiler.directives_add
Compiler.directives_clear
Compiler.directives_print
Compiler.directives_remove
Compiler.perfmap
Compiler.queue
GC.class_histogram
GC.finalizer_info
GC.heap_dump
GC.heap_info
GC.run
GC.run_finalization
JFR.check
JFR.configure
JFR.dump
JFR.start
JFR.stop
JFR.view
JVMTI.agent_load
JVMTI.data_dump
ManagementAgent.start
ManagementAgent.start_local
ManagementAgent.status
ManagementAgent.stop
System.native_heap_info
System.trim_native_heap
Thread.dump_to_file
Thread.print
VM.cds
VM.class_hierarchy
VM.classes
VM.classloader_stats
VM.classloaders
VM.command_line
VM.dynlibs
VM.events
VM.flags
VM.info
VM.log
VM.metaspace
VM.native_memory
VM.set_flag
VM.stringtable
VM.symboltable
VM.system_properties
VM.systemdictionary
VM.uptime
VM.version
helpjcmd - Help for a specific diagnostic command
jcmd $PID/$Main_Class help $commandeg: jcmd 38388 help VM.version
jcmd - List system properties of a JVM process
jcmd $PID VM.system_properties | sort# e.g.
$ jcmd 3390 VM.system_properties
3390:
#Sun Feb 04 15:06:55 AEDT 2024
CONSOLE_LOG_CHARSET=UTF-8
FILE_LOG_CHARSET=UTF-8
LOG_FILE=/tmp/spring.log
LOG_PATH=/tmp
PID=3390
catalina.base=/tmp/tomcat.8080.470854316564232780
catalina.home=/tmp/tomcat.8080.470854316564232780
catalina.useNaming=false
file.encoding=UTF-8
file.separator=/
java.awt.headless=truejcmd - List JVM flags
jcmd $PID VM.flags | tr " " "\n" | sortor
jinfo -flags $PID | tr " " "\n" | sortjcmd - Show JMX
jinfo
jinfo - List system properties of a JVM process
jinfo -sysprops $PID | sortjinfo - Print the value of the specified VM flag
jinfo -flag $namejinfo - Enable/Disable the specified VM flag
jinfo -flag [+|-]$namejshell
JMX (Java Management Extension)
com.sun.management.jmxremote.ssl = true [default]
com.sun.management.config.file = management.properties [default]
com.sun.management.jmxremote.local.only = true [default]
com.sun.management.jmxremote.access.file = jmxremote.access [default]
com.sun.management.jmxremote.port = 0 [default]
com.sun.management.jmxremote.registry.ssl = false [default]
com.sun.management.jmxremote.authenticate = true [default]
com.sun.management.jmxremote.ssl.need.client.auth = false [default]
com.sun.management.jmxremote.password.file = jmxremote.password [default]JDP
-
A manageable JVM is one that has the JMX agent running.
-
Resources
GUI
JMC (JDK Mission Control)
JMC - Source Code (opens in a new tab)
JMC - JDK Mission Control (opens in a new tab)
jol (Java Object Layout)
-
Estimate how much memory an object takes
-
Resources
VisualVM
-
Cannot start up, failing to find Java runtime
-
Use
visualvm.conf-
Edit
$VISUALVM_INSTALLATION/etc/visualvm.conf -
Uncomment
visualvm_jdkhome="/path/to/jdk" -
Specify JDK directory
-
Resources
-
-
Use command line arguments
visualvm.exe --jdkhome $JAVA_HOME
-
References
Reference - Bytecode
- Wikipedia - Java bytecode (opens in a new tab)
- Wikipedia - Java bytecode instruction listings (opens in a new tab)
- IBM Developerworks - Java bytecode: Understanding bytecode makes you a better programmer (opens in a new tab)
Reference - JVM
- Wikipedia - Java virtual machine - Virtual machine architecture (opens in a new tab)
- Oracle - Java Language and Virtual Machine Specifications (opens in a new tab)
- Ionut Balosin - HotSpot JVM Performance Tuning Guidelines (opens in a new tab)
- DZone - 7 JVM Arguments of Highly Effective Applications (opens in a new tab)
- jvmperf: Java Performance Workshop (opens in a new tab)