java.1 195 ko
Newer Older
Axel PERSEVALLE's avatar
Axel PERSEVALLE a validé
.\" Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
Axel PERSEVALLE's avatar
Axel PERSEVALLE a validé
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code is distributed in the hope that it will be useful, but WITHOUT
.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
.\" FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\"t
.\" Automatically generated by Pandoc 2.3.1
.\"
.TH "JAVA" "1" "2021" "JDK 17" "JDK Commands"
.hy
.SH NAME
.PP
java \- launch a Java application
.SH SYNOPSIS
.PP
To launch a class file:
.PP
\f[CB]java\f[R] [\f[I]options\f[R]] \f[I]mainclass\f[R] [\f[I]args\f[R] ...]
.PP
To launch the main class in a JAR file:
.PP
\f[CB]java\f[R] [\f[I]options\f[R]] \f[CB]\-jar\f[R] \f[I]jarfile\f[R]
[\f[I]args\f[R] ...]
.PP
To launch the main class in a module:
.PP
\f[CB]java\f[R] [\f[I]options\f[R]] \f[CB]\-m\f[R]
\f[I]module\f[R][\f[CB]/\f[R]\f[I]mainclass\f[R]] [\f[I]args\f[R] ...]
.PP
or
.PP
\f[CB]java\f[R] [\f[I]options\f[R]] \f[CB]\-\-module\f[R]
\f[I]module\f[R][\f[CB]/\f[R]\f[I]mainclass\f[R]] [\f[I]args\f[R] ...]
.PP
To launch a single source\-file program:
.PP
\f[CB]java\f[R] [\f[I]options\f[R]] \f[I]source\-file\f[R] [\f[I]args\f[R]
\&...]
.TP
.B \f[I]options\f[R]
Optional: Specifies command\-line options separated by spaces.
See \f[B]Overview of Java Options\f[R] for a description of available
options.
.RS
.RE
.TP
.B \f[I]mainclass\f[R]
Specifies the name of the class to be launched.
Command\-line entries following \f[CB]classname\f[R] are the arguments for
the main method.
.RS
.RE
.TP
.B \f[CB]\-jar\f[R] \f[I]jarfile\f[R]
Executes a program encapsulated in a JAR file.
The \f[I]jarfile\f[R] argument is the name of a JAR file with a manifest
that contains a line in the form \f[CB]Main\-Class:\f[R]\f[I]classname\f[R]
that defines the class with the
\f[CB]public\ static\ void\ main(String[]\ args)\f[R] method that serves
as your application\[aq]s starting point.
When you use \f[CB]\-jar\f[R], the specified JAR file is the source of all
user classes, and other class path settings are ignored.
If you\[aq]re using JAR files, then see \f[B]jar\f[R].
.RS
.RE
.TP
.B \f[CB]\-m\f[R] or \f[CB]\-\-module\f[R] \f[I]module\f[R][\f[CB]/\f[R]\f[I]mainclass\f[R]]
Executes the main class in a module specified by \f[I]mainclass\f[R] if
it is given, or, if it is not given, the value in the \f[I]module\f[R].
In other words, \f[I]mainclass\f[R] can be used when it is not specified
by the module, or to override the value when it is specified.
.RS
.PP
See \f[B]Standard Options for Java\f[R].
.RE
.TP
.B \f[I]source\-file\f[R]
Only used to launch a single source\-file program.
Specifies the source file that contains the main class when using
source\-file mode.
See \f[B]Using Source\-File Mode to Launch Single\-File Source\-Code
Programs\f[R]
.RS
.RE
.TP
.B \f[I]args\f[R] ...
Optional: Arguments following \f[I]mainclass\f[R], \f[I]source\-file\f[R],
\f[CB]\-jar\f[R] \f[I]jarfile\f[R], and \f[CB]\-m\f[R] or \f[CB]\-\-module\f[R]
\f[I]module\f[R]\f[CB]/\f[R]\f[I]mainclass\f[R] are passed as arguments to
the main class.
.RS
.RE
.SH DESCRIPTION
.PP
The \f[CB]java\f[R] command starts a Java application.
It does this by starting the Java Virtual Machine (JVM), loading the
specified class, and calling that class\[aq]s \f[CB]main()\f[R] method.
The method must be declared \f[CB]public\f[R] and \f[CB]static\f[R], it must
not return any value, and it must accept a \f[CB]String\f[R] array as a
parameter.
The method declaration has the following form:
.RS
.PP
\f[CB]public\ static\ void\ main(String[]\ args)\f[R]
.RE
.PP
In source\-file mode, the \f[CB]java\f[R] command can launch a class
declared in a source file.
See \f[B]Using Source\-File Mode to Launch Single\-File Source\-Code
Programs\f[R] for a description of using the source\-file mode.
.RS
.PP
\f[B]Note:\f[R] You can use the \f[CB]JDK_JAVA_OPTIONS\f[R] launcher
environment variable to prepend its content to the actual command line
of the \f[CB]java\f[R] launcher.
See \f[B]Using the JDK_JAVA_OPTIONS Launcher Environment Variable\f[R].
.RE
.PP
By default, the first argument that isn\[aq]t an option of the
\f[CB]java\f[R] command is the fully qualified name of the class to be
called.
If \f[CB]\-jar\f[R] is specified, then its argument is the name of the JAR
file containing class and resource files for the application.
The startup class must be indicated by the \f[CB]Main\-Class\f[R] manifest
header in its manifest file.
.PP
Arguments after the class file name or the JAR file name are passed to
the \f[CB]main()\f[R] method.
.SS \f[CB]javaw\f[R]
.PP
\f[B]Windows:\f[R] The \f[CB]javaw\f[R] command is identical to
\f[CB]java\f[R], except that with \f[CB]javaw\f[R] there\[aq]s no associated
console window.
Use \f[CB]javaw\f[R] when you don\[aq]t want a command prompt window to
appear.
The \f[CB]javaw\f[R] launcher will, however, display a dialog box with
error information if a launch fails.
.SH USING SOURCE\-FILE MODE TO LAUNCH SINGLE\-FILE SOURCE\-CODE PROGRAMS
.PP
To launch a class declared in a source file, run the \f[CB]java\f[R]
launcher in source\-file mode.
Entering source\-file mode is determined by two items on the
\f[CB]java\f[R] command line:
.IP \[bu] 2
The first item on the command line that is not an option or part of an
option.
In other words, the item in the command line that would otherwise be the
main class name.
.IP \[bu] 2
The \f[CB]\-\-source\f[R] \f[I]version\f[R] option, if present.
.PP
If the class identifies an existing file that has a \f[CB]\&.java\f[R]
extension, or if the \f[CB]\-\-source\f[R] option is specified, then
source\-file mode is selected.
The source file is then compiled and run.
The \f[CB]\-\-source\f[R] option can be used to specify the source
\f[I]version\f[R] or \f[I]N\f[R] of the source code.
This determines the API that can be used.
When you set \f[CB]\-\-source\f[R] \f[I]N\f[R], you can only use the public
API that was defined in JDK \f[I]N\f[R].
.RS
.PP
\f[B]Note:\f[R] The valid values of \f[I]N\f[R] change for each release,
with new values added and old values removed.
You\[aq]ll get an error message if you use a value of \f[I]N\f[R] that is
no longer supported.
The supported values of \f[I]N\f[R] are the current Java SE release
(\f[CB]17\f[R]) and a limited number of previous releases, detailed in the
command\-line help for \f[CB]javac\f[R], under the \f[CB]\-\-source\f[R] and
\f[CB]\-\-release\f[R] options.
.RE
.PP
If the file does not have the \f[CB]\&.java\f[R] extension, the
\f[CB]\-\-source\f[R] option must be used to tell the \f[CB]java\f[R]
command to use the source\-file mode.
The \f[CB]\-\-source\f[R] option is used for cases when the source file is
a "script" to be executed and the name of the source file does not
follow the normal naming conventions for Java source files.
.PP
In source\-file mode, the effect is as though the source file is
compiled into memory, and the first class found in the source file is
executed.
Any arguments placed after the name of the source file in the original
command line are passed to the compiled class when it is executed.
.PP
For example, if a file were named \f[CB]HelloWorld.java\f[R] and contained
a class named \f[CB]hello.World\f[R], then the source\-file mode command
to launch the class would be:
.RS
.PP
\f[CB]java\ HelloWorld.java\f[R]
.RE
.PP
The example illustrates that the class can be in a named package, and
does not need to be in the unnamed package.
This use of source\-file mode is informally equivalent to using the
following two commands where \f[CB]hello.World\f[R] is the name of the
class in the package:
.IP
.nf
\f[CB]
javac\ \-d\ <memory>\ HelloWorld.java
java\ \-cp\ <memory>\ hello.World
\f[R]
.fi
.PP
\f[B]In source\-file mode, any additional command\-line options are
processed as follows:\f[R]
.IP \[bu] 2
The launcher scans the options specified before the source file for any
that are relevant in order to compile the source file.
.RS 2
.PP
This includes: \f[CB]\-\-class\-path\f[R], \f[CB]\-\-module\-path\f[R],
\f[CB]\-\-add\-exports\f[R], \f[CB]\-\-add\-modules\f[R],
\f[CB]\-\-limit\-modules\f[R], \f[CB]\-\-patch\-module\f[R],
\f[CB]\-\-upgrade\-module\-path\f[R], and any variant forms of those
options.
It also includes the new \f[CB]\-\-enable\-preview\f[R] option, described
in JEP 12.
.RE
.IP \[bu] 2
No provision is made to pass any additional options to the compiler,
such as \f[CB]\-processor\f[R] or \f[CB]\-Werror\f[R].
.IP \[bu] 2
Command\-line argument files (\f[CB]\@\f[R]\-files) may be used in the
standard way.
Long lists of arguments for either the VM or the program being invoked
may be placed in files specified on the command\-line by prefixing the
filename with an \f[CB]\@\f[R] character.
.PP
\f[B]In source\-file mode, compilation proceeds as follows:\f[R]
.IP \[bu] 2
Any command\-line options that are relevant to the compilation
environment are taken into account.
.IP \[bu] 2
No other source files are found and compiled, as if the source path is
set to an empty value.
.IP \[bu] 2
Annotation processing is disabled, as if \f[CB]\-proc:none\f[R] is in
effect.
.IP \[bu] 2
If a version is specified, via the \f[CB]\-\-source\f[R] option, the value
is used as the argument for an implicit \f[CB]\-\-release\f[R] option for
the compilation.
This sets both the source version accepted by compiler and the system
API that may be used by the code in the source file.
.IP \[bu] 2
The source file is compiled in the context of an unnamed module.
.IP \[bu] 2
The source file should contain one or more top\-level classes, the first
of which is taken as the class to be executed.
.IP \[bu] 2
The compiler does not enforce the optional restriction defined at the
end of JLS ??7.6, that a type in a named package should exist in a file
whose name is composed from the type name followed by the
\f[CB]\&.java\f[R] extension.
.IP \[bu] 2
If the source file contains errors, appropriate error messages are
written to the standard error stream, and the launcher exits with a
non\-zero exit code.
.PP
\f[B]In source\-file mode, execution proceeds as follows:\f[R]
.IP \[bu] 2
The class to be executed is the first top\-level class found in the
source file.
It must contain a declaration of the standard
\f[CB]public\ static\ void\ main(String[])\f[R] method.
.IP \[bu] 2
The compiled classes are loaded by a custom class loader, that delegates
to the application class loader.
This implies that classes appearing on the application class path cannot
refer to any classes declared in the source file.
.IP \[bu] 2
The compiled classes are executed in the context of an unnamed module,
as though \f[CB]\-\-add\-modules=ALL\-DEFAULT\f[R] is in effect.
This is in addition to any other \f[CB]\-\-add\-module\f[R] options that
may be have been specified on the command line.
.IP \[bu] 2
Any arguments appearing after the name of the file on the command line
are passed to the standard main method in the obvious way.
.IP \[bu] 2
It is an error if there is a class on the application class path whose
name is the same as that of the class to be executed.
.PP
See \f[B]JEP 330: Launch Single\-File Source\-Code Programs\f[R]
[http://openjdk.java.net/jeps/330] for complete details.
.SH USING THE JDK_JAVA_OPTIONS LAUNCHER ENVIRONMENT VARIABLE
.PP
\f[CB]JDK_JAVA_OPTIONS\f[R] prepends its content to the options parsed
from the command line.
The content of the \f[CB]JDK_JAVA_OPTIONS\f[R] environment variable is a
list of arguments separated by white\-space characters (as determined by
\f[CB]isspace()\f[R]).
These are prepended to the command line arguments passed to
\f[CB]java\f[R] launcher.
The encoding requirement for the environment variable is the same as the
\f[CB]java\f[R] command line on the system.
\f[CB]JDK_JAVA_OPTIONS\f[R] environment variable content is treated in the
same manner as that specified in the command line.
.PP
Single (\f[CB]\[aq]\f[R]) or double (\f[CB]"\f[R]) quotes can be used to
enclose arguments that contain whitespace characters.
All content between the open quote and the first matching close quote
are preserved by simply removing the pair of quotes.
In case a matching quote is not found, the launcher will abort with an
error message.
\f[CB]\@\f[R]\-files are supported as they are specified in the command
line.
However, as in \f[CB]\@\f[R]\-files, use of a wildcard is not supported.
In order to mitigate potential misuse of \f[CB]JDK_JAVA_OPTIONS\f[R]
behavior, options that specify the main class (such as \f[CB]\-jar\f[R])
or cause the \f[CB]java\f[R] launcher to exit without executing the main
class (such as \f[CB]\-h\f[R]) are disallowed in the environment variable.
If any of these options appear in the environment variable, the launcher
will abort with an error message.
When \f[CB]JDK_JAVA_OPTIONS\f[R] is set, the launcher prints a message to
stderr as a reminder.
.PP
\f[B]Example:\f[R]
.IP
.nf
\f[CB]
$\ export\ JDK_JAVA_OPTIONS=\[aq]\-g\ \@file1\ \-Dprop=value\ \@file2\ \-Dws.prop="white\ spaces"\[aq]
$\ java\ \-Xint\ \@file3
\f[R]
.fi
.PP
is equivalent to the command line:
.IP
.nf
\f[CB]
java\ \-g\ \@file1\ \-Dprop=value\ \@file2\ \-Dws.prop="white\ spaces"\ \-Xint\ \@file3
\f[R]
.fi
.SH OVERVIEW OF JAVA OPTIONS
.PP
The \f[CB]java\f[R] command supports a wide range of options in the
following categories:
.IP \[bu] 2
\f[B]Standard Options for Java\f[R]: Options guaranteed to be supported
by all implementations of the Java Virtual Machine (JVM).
They\[aq]re used for common actions, such as checking the version of the
JRE, setting the class path, enabling verbose output, and so on.
.IP \[bu] 2
\f[B]Extra Options for Java\f[R]: General purpose options that are
specific to the Java HotSpot Virtual Machine.
They aren\[aq]t guaranteed to be supported by all JVM implementations,
and are subject to change.
These options start with \f[CB]\-X\f[R].
.PP
The advanced options aren\[aq]t recommended for casual use.
These are developer options used for tuning specific areas of the Java
HotSpot Virtual Machine operation that often have specific system
requirements and may require privileged access to system configuration
parameters.
Several examples of performance tuning are provided in \f[B]Performance
Tuning Examples\f[R].
These options aren\[aq]t guaranteed to be supported by all JVM
implementations and are subject to change.
Advanced options start with \f[CB]\-XX\f[R].
.IP \[bu] 2
\f[B]Advanced Runtime Options for Java\f[R]: Control the runtime behavior
of the Java HotSpot VM.
.IP \[bu] 2
\f[B]Advanced JIT Compiler Options for java\f[R]: Control the dynamic
just\-in\-time (JIT) compilation performed by the Java HotSpot VM.
.IP \[bu] 2
\f[B]Advanced Serviceability Options for Java\f[R]: Enable gathering
system information and performing extensive debugging.
.IP \[bu] 2
\f[B]Advanced Garbage Collection Options for Java\f[R]: Control how
garbage collection (GC) is performed by the Java HotSpot
.PP
Boolean options are used to either enable a feature that\[aq]s disabled
by default or disable a feature that\[aq]s enabled by default.
Such options don\[aq]t require a parameter.
Boolean \f[CB]\-XX\f[R] options are enabled using the plus sign
(\f[CB]\-XX:+\f[R]\f[I]OptionName\f[R]) and disabled using the minus sign
(\f[CB]\-XX:\-\f[R]\f[I]OptionName\f[R]).
.PP
For options that require an argument, the argument may be separated from
the option name by a space, a colon (:), or an equal sign (=), or the
argument may directly follow the option (the exact syntax differs for
each option).
If you\[aq]re expected to specify the size in bytes, then you can use no
suffix, or use the suffix \f[CB]k\f[R] or \f[CB]K\f[R] for kilobytes (KB),
\f[CB]m\f[R] or \f[CB]M\f[R] for megabytes (MB), or \f[CB]g\f[R] or \f[CB]G\f[R]
for gigabytes (GB).
For example, to set the size to 8 GB, you can specify either
\f[CB]8g\f[R], \f[CB]8192m\f[R], \f[CB]8388608k\f[R], or \f[CB]8589934592\f[R]
as the argument.
If you are expected to specify the percentage, then use a number from 0
to 1.
For example, specify \f[CB]0.25\f[R] for 25%.
.PP
The following sections describe the options that are obsolete,
deprecated, and removed:
.IP \[bu] 2
\f[B]Deprecated Java Options\f[R]: Accepted and acted upon \-\-\- a
warning is issued when they\[aq]re used.
.IP \[bu] 2
\f[B]Obsolete Java Options\f[R]: Accepted but ignored \-\-\- a warning is
issued when they\[aq]re used.
.IP \[bu] 2
\f[B]Removed Java Options\f[R]: Removed \-\-\- using them results in an
error.
.SH STANDARD OPTIONS FOR JAVA
.PP
These are the most commonly used options supported by all
implementations of the JVM.
.RS
.PP
\f[B]Note:\f[R] To specify an argument for a long option, you can use
either \f[CB]\-\-\f[R]\f[I]name\f[R]\f[CB]=\f[R]\f[I]value\f[R] or
\f[CB]\-\-\f[R]\f[I]name\f[R] \f[I]value\f[R].
.RE
.TP
.B \f[CB]\-agentlib:\f[R]\f[I]libname\f[R][\f[CB]=\f[R]\f[I]options\f[R]]
Loads the specified native agent library.
After the library name, a comma\-separated list of options specific to
the library can be used.
.RS
.IP \[bu] 2
\f[B]Linux and macOS:\f[R] If the option \f[CB]\-agentlib:foo\f[R] is
specified, then the JVM attempts to load the library named
\f[CB]libfoo.so\f[R] in the location specified by the
\f[CB]LD_LIBRARY_PATH\f[R] system variable (on macOS this variable is
\f[CB]DYLD_LIBRARY_PATH\f[R]).
.IP \[bu] 2
\f[B]Windows:\f[R] If the option \f[CB]\-agentlib:foo\f[R] is specified,
then the JVM attempts to load the library named \f[CB]foo.dll\f[R] in the
location specified by the \f[CB]PATH\f[R] system variable.
.RS 2
.PP
The following example shows how to load the Java Debug Wire Protocol
(JDWP) library and listen for the socket connection on port 8000,
suspending the JVM before the main class loads:
.RS
.PP
\f[CB]\-agentlib:jdwp=transport=dt_socket,server=y,address=8000\f[R]
.RE
.RE
.RE
.TP
.B \f[CB]\-agentpath:\f[R]\f[I]pathname\f[R][\f[CB]=\f[R]\f[I]options\f[R]]
Loads the native agent library specified by the absolute path name.
This option is equivalent to \f[CB]\-agentlib\f[R] but uses the full path
and file name of the library.
.RS
.RE
.TP
.B \f[CB]\-\-class\-path\f[R] \f[I]classpath\f[R], \f[CB]\-classpath\f[R] \f[I]classpath\f[R], or \f[CB]\-cp\f[R] \f[I]classpath\f[R]
A semicolon (\f[CB];\f[R]) separated list of directories, JAR archives,
and ZIP archives to search for class files.
.RS
.PP
Specifying \f[I]classpath\f[R] overrides any setting of the
\f[CB]CLASSPATH\f[R] environment variable.
If the class path option isn\[aq]t used and \f[I]classpath\f[R] isn\[aq]t
set, then the user class path consists of the current directory (.).
.PP
As a special convenience, a class path element that contains a base name
of an asterisk (*) is considered equivalent to specifying a list of all
the files in the directory with the extension \f[CB]\&.jar\f[R] or
\f[CB]\&.JAR\f[R] .
A Java program can\[aq]t tell the difference between the two
invocations.
For example, if the directory mydir contains \f[CB]a.jar\f[R] and
\f[CB]b.JAR\f[R], then the class path element mydir/* is expanded to
\f[CB]A.jar:b.JAR\f[R], except that the order of JAR files is unspecified.
All \f[CB]\&.jar\f[R] files in the specified directory, even hidden ones,
are included in the list.
A class path entry consisting of an asterisk (*) expands to a list of
all the jar files in the current directory.
The \f[CB]CLASSPATH\f[R] environment variable, where defined, is similarly
expanded.
Any class path wildcard expansion that occurs before the Java VM is
started.
Java programs never see wildcards that aren\[aq]t expanded except by
querying the environment, such as by calling
\f[CB]System.getenv("CLASSPATH")\f[R].
.RE
.TP
.B \f[CB]\-\-disable\-\@files\f[R]
Can be used anywhere on the command line, including in an argument file,
to prevent further \f[CB]\@filename\f[R] expansion.
This option stops expanding \f[CB]\@\f[R]\-argfiles after the option.
.RS
.RE
.TP
.B \f[CB]\-\-enable\-preview\f[R]
Allows classes to depend on \f[B]preview features\f[R]
[https://docs.oracle.com/en/java/javase/12/language/index.html#JSLAN\-GUID\-5A82FE0E\-0CA4\-4F1F\-B075\-564874FE2823]
of the release.
.RS
.RE
.TP
.B \f[CB]\-\-module\-path\f[R] \f[I]modulepath\f[R]... or \f[CB]\-p\f[R] \f[I]modulepath\f[R]
A semicolon (\f[CB];\f[R]) separated list of directories in which each
directory is a directory of modules.
.RS
.RE
.TP
.B \f[CB]\-\-upgrade\-module\-path\f[R] \f[I]modulepath\f[R]...
A semicolon (\f[CB];\f[R]) separated list of directories in which each
directory is a directory of modules that replace upgradeable modules in
the runtime image.
.RS
.RE
.TP
.B \f[CB]\-\-add\-modules\f[R] \f[I]module\f[R][\f[CB],\f[R]\f[I]module\f[R]...]
Specifies the root modules to resolve in addition to the initial module.
\f[I]module\f[R] also can be \f[CB]ALL\-DEFAULT\f[R], \f[CB]ALL\-SYSTEM\f[R],
and \f[CB]ALL\-MODULE\-PATH\f[R].
.RS
.RE
.TP
.B \f[CB]\-\-list\-modules\f[R]
Lists the observable modules and then exits.
.RS
.RE
.TP
.B \f[CB]\-d\f[R] \f[I]module_name\f[R] or \f[CB]\-\-describe\-module\f[R] \f[I]module_name\f[R]
Describes a specified module and then exits.
.RS
.RE
.TP
.B \f[CB]\-\-dry\-run\f[R]
Creates the VM but doesn\[aq]t execute the main method.
This \f[CB]\-\-dry\-run\f[R] option might be useful for validating the
command\-line options such as the module system configuration.
.RS
.RE
.TP
.B \f[CB]\-\-validate\-modules\f[R]
Validates all modules and exit.
This option is helpful for finding conflicts and other errors with
modules on the module path.
.RS
.RE
.TP
.B \f[CB]\-D\f[R]\f[I]property\f[R]\f[CB]=\f[R]\f[I]value\f[R]
Sets a system property value.
The \f[I]property\f[R] variable is a string with no spaces that
represents the name of the property.
The \f[I]value\f[R] variable is a string that represents the value of the
property.
If \f[I]value\f[R] is a string with spaces, then enclose it in quotation
marks (for example \f[CB]\-Dfoo="foo\ bar"\f[R]).
.RS
.RE
.TP
.B \f[CB]\-disableassertions\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]] or \f[CB]\-da\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]]
Disables assertions.
By default, assertions are disabled in all packages and classes.
With no arguments, \f[CB]\-disableassertions\f[R] (\f[CB]\-da\f[R]) disables
assertions in all packages and classes.
With the \f[I]packagename\f[R] argument ending in \f[CB]\&...\f[R], the
switch disables assertions in the specified package and any subpackages.
If the argument is simply \f[CB]\&...\f[R], then the switch disables
assertions in the unnamed package in the current working directory.
With the \f[I]classname\f[R] argument, the switch disables assertions in
the specified class.
.RS
.PP
The \f[CB]\-disableassertions\f[R] (\f[CB]\-da\f[R]) option applies to all
class loaders and to system classes (which don\[aq]t have a class
loader).
There\[aq]s one exception to this rule: If the option is provided with
no arguments, then it doesn\[aq]t apply to system classes.
This makes it easy to disable assertions in all classes except for
system classes.
The \f[CB]\-disablesystemassertions\f[R] option enables you to disable
assertions in all system classes.
To explicitly enable assertions in specific packages or classes, use the
\f[CB]\-enableassertions\f[R] (\f[CB]\-ea\f[R]) option.
Both options can be used at the same time.
For example, to run the \f[CB]MyClass\f[R] application with assertions
enabled in the package \f[CB]com.wombat.fruitbat\f[R] (and any
subpackages) but disabled in the class
\f[CB]com.wombat.fruitbat.Brickbat\f[R], use the following command:
.RS
.PP
\f[CB]java\ \-ea:com.wombat.fruitbat...\ \-da:com.wombat.fruitbat.Brickbat\ MyClass\f[R]
.RE
.RE
.TP
.B \f[CB]\-disablesystemassertions\f[R] or \f[CB]\-dsa\f[R]
Disables assertions in all system classes.
.RS
.RE
.TP
.B \f[CB]\-enableassertions\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]] or \f[CB]\-ea\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]]
Enables assertions.
By default, assertions are disabled in all packages and classes.
With no arguments, \f[CB]\-enableassertions\f[R] (\f[CB]\-ea\f[R]) enables
assertions in all packages and classes.
With the \f[I]packagename\f[R] argument ending in \f[CB]\&...\f[R], the
switch enables assertions in the specified package and any subpackages.
If the argument is simply \f[CB]\&...\f[R], then the switch enables
assertions in the unnamed package in the current working directory.
With the \f[I]classname\f[R] argument, the switch enables assertions in
the specified class.
.RS
.PP
The \f[CB]\-enableassertions\f[R] (\f[CB]\-ea\f[R]) option applies to all
class loaders and to system classes (which don\[aq]t have a class
loader).
There\[aq]s one exception to this rule: If the option is provided with
no arguments, then it doesn\[aq]t apply to system classes.
This makes it easy to enable assertions in all classes except for system
classes.
The \f[CB]\-enablesystemassertions\f[R] option provides a separate switch
to enable assertions in all system classes.
To explicitly disable assertions in specific packages or classes, use
the \f[CB]\-disableassertions\f[R] (\f[CB]\-da\f[R]) option.
If a single command contains multiple instances of these switches, then
they\[aq]re processed in order, before loading any classes.
For example, to run the \f[CB]MyClass\f[R] application with assertions
enabled only in the package \f[CB]com.wombat.fruitbat\f[R] (and any
subpackages) but disabled in the class
\f[CB]com.wombat.fruitbat.Brickbat\f[R], use the following command:
.RS
.PP
\f[CB]java\ \-ea:com.wombat.fruitbat...\ \-da:com.wombat.fruitbat.Brickbat\ MyClass\f[R]
.RE
.RE
.TP
.B \f[CB]\-enablesystemassertions\f[R] or \f[CB]\-esa\f[R]
Enables assertions in all system classes.
.RS
.RE
.TP
.B \f[CB]\-help\f[R], \f[CB]\-h\f[R], or \f[CB]\-?\f[R]
Prints the help message to the error stream.
.RS
.RE
.TP
.B \f[CB]\-\-help\f[R]
Prints the help message to the output stream.
.RS
.RE
.TP
.B \f[CB]\-javaagent:\f[R]\f[I]jarpath\f[R][\f[CB]=\f[R]\f[I]options\f[R]]
Loads the specified Java programming language agent.
See \f[CB]java.lang.instrument\f[R].
.RS
.RE
.TP
.B \f[CB]\-\-show\-version\f[R]
Prints the product version to the output stream and continues.
.RS
.RE
.TP
.B \f[CB]\-showversion\f[R]
Prints the product version to the error stream and continues.
.RS
.RE
.TP
.B \f[CB]\-\-show\-module\-resolution\f[R]
Shows module resolution output during startup.
.RS
.RE
.TP
.B \f[CB]\-splash:\f[R]\f[I]imagepath\f[R]
Shows the splash screen with the image specified by \f[I]imagepath\f[R].
HiDPI scaled images are automatically supported and used if available.
The unscaled image file name, such as \f[CB]image.ext\f[R], should always
be passed as the argument to the \f[CB]\-splash\f[R] option.
The most appropriate scaled image provided is picked up automatically.
.RS
.PP
For example, to show the \f[CB]splash.gif\f[R] file from the
\f[CB]images\f[R] directory when starting your application, use the
following option:
.RS
.PP
\f[CB]\-splash:images/splash.gif\f[R]
.RE
.PP
See the SplashScreen API documentation for more information.
.RE
.TP
.B \f[CB]\-verbose:class\f[R]
Displays information about each loaded class.
.RS
.RE
.TP
.B \f[CB]\-verbose:gc\f[R]
Displays information about each garbage collection (GC) event.
.RS
.RE
.TP
.B \f[CB]\-verbose:jni\f[R]
Displays information about the use of native methods and other Java
Native Interface (JNI) activity.
.RS
.RE
.TP
.B \f[CB]\-verbose:module\f[R]
Displays information about the modules in use.
.RS
.RE
.TP
.B \f[CB]\-\-version\f[R]
Prints product version to the output stream and exits.
.RS
.RE
.TP
.B \f[CB]\-version\f[R]
Prints product version to the error stream and exits.
.RS
.RE
.TP
.B \f[CB]\-X\f[R]
Prints the help on extra options to the error stream.
.RS
.RE
.TP
.B \f[CB]\-\-help\-extra\f[R]
Prints the help on extra options to the output stream.
.RS
.RE
.TP
.B \f[CB]\@\f[R]\f[I]argfile\f[R]
Specifies one or more argument files prefixed by \f[CB]\@\f[R] used by the
\f[CB]java\f[R] command.
It isn\[aq]t uncommon for the \f[CB]java\f[R] command line to be very long
because of the \f[CB]\&.jar\f[R] files needed in the classpath.
The \f[CB]\@\f[R]\f[I]argfile\f[R] option overcomes command\-line length
limitations by enabling the launcher to expand the contents of argument
files after shell expansion, but before argument processing.
Contents in the argument files are expanded because otherwise, they
would be specified on the command line until the
\f[CB]\-\-disable\-\@files\f[R] option was encountered.
.RS
.PP
The argument files can also contain the main class name and all options.
If an argument file contains all of the options required by the
\f[CB]java\f[R] command, then the command line could simply be:
.RS
.PP
\f[CB]java\ \@\f[R]\f[I]argfile\f[R]
.RE
.PP
See \f[B]java Command\-Line Argument Files\f[R] for a description and
examples of using \f[CB]\@\f[R]\-argfiles.
.RE
.SH EXTRA OPTIONS FOR JAVA
.PP
The following \f[CB]java\f[R] options are general purpose options that are
specific to the Java HotSpot Virtual Machine.
.TP
.B \f[CB]\-Xbatch\f[R]
Disables background compilation.
By default, the JVM compiles the method as a background task, running
the method in interpreter mode until the background compilation is
finished.
The \f[CB]\-Xbatch\f[R] flag disables background compilation so that
compilation of all methods proceeds as a foreground task until
completed.
This option is equivalent to \f[CB]\-XX:\-BackgroundCompilation\f[R].
.RS
.RE
.TP
.B \f[CB]\-Xbootclasspath/a:\f[R]\f[I]directories\f[R]|\f[I]zip\f[R]|\f[I]JAR\-files\f[R]
Specifies a list of directories, JAR files, and ZIP archives to append
to the end of the default bootstrap class path.
.RS
.PP
\f[B]Linux and macOS:\f[R] Colons (\f[CB]:\f[R]) separate entities in this
list.
.PP
\f[B]Windows:\f[R] Semicolons (\f[CB];\f[R]) separate entities in this
list.
.RE
.TP
.B \f[CB]\-Xcheck:jni\f[R]
Performs additional checks for Java Native Interface (JNI) functions.
.RS
.PP
The following checks are considered indicative of significant problems
with the native code, and the JVM terminates with an irrecoverable error
in such cases:
.IP \[bu] 2
The thread doing the call is not attached to the JVM.
.IP \[bu] 2
The thread doing the call is using the \f[CB]JNIEnv\f[R] belonging to
another thread.
.IP \[bu] 2
A parameter validation check fails:
.RS 2
.IP \[bu] 2
A \f[CB]jfieldID\f[R], or \f[CB]jmethodID\f[R], is detected as being
invalid.
For example:
.RS 2
.IP \[bu] 2
Of the wrong type
.IP \[bu] 2
Associated with the wrong class
.RE
.IP \[bu] 2
A parameter of the wrong type is detected.
.IP \[bu] 2
An invalid parameter value is detected.
For example:
.RS 2
.IP \[bu] 2
NULL where not permitted
.IP \[bu] 2
An out\-of\-bounds array index, or frame capacity
.IP \[bu] 2
A non\-UTF\-8 string
.IP \[bu] 2
An invalid JNI reference
.IP \[bu] 2
An attempt to use a \f[CB]ReleaseXXX\f[R] function on a parameter not
produced by the corresponding \f[CB]GetXXX\f[R] function
.RE
.RE
.PP
The following checks only result in warnings being printed:
.IP \[bu] 2
A JNI call was made without checking for a pending exception from a
previous JNI call, and the current call is not safe when an exception
may be pending.
.IP \[bu] 2
The number of JNI local references existing when a JNI function
terminates exceeds the number guaranteed to be available.
See the \f[CB]EnsureLocalcapacity\f[R] function.
.IP \[bu] 2
A class descriptor is in decorated format (\f[CB]Lname;\f[R]) when it
should not be.
.IP \[bu] 2
A \f[CB]NULL\f[R] parameter is allowed, but its use is questionable.
.IP \[bu] 2
Calling other JNI functions in the scope of
\f[CB]Get/ReleasePrimitiveArrayCritical\f[R] or
\f[CB]Get/ReleaseStringCritical\f[R]
.PP
Expect a performance degradation when this option is used.
.RE
.TP
.B \f[CB]\-Xdebug\f[R]
Does nothing.
Provided for backward compatibility.
.RS
.RE
.TP
.B \f[CB]\-Xdiag\f[R]
Shows additional diagnostic messages.
.RS
.RE
.TP
.B \f[CB]\-Xint\f[R]
Runs the application in interpreted\-only mode.
Compilation to native code is disabled, and all bytecode is executed by
the interpreter.
The performance benefits offered by the just\-in\-time (JIT) compiler
aren\[aq]t present in this mode.
.RS
.RE
.TP
.B \f[CB]\-Xinternalversion\f[R]
Displays more detailed JVM version information than the
\f[CB]\-version\f[R] option, and then exits.
.RS
.RE
.TP
.B \f[CB]\-Xlog:\f[R]\f[I]option\f[R]
Configure or enable logging with the Java Virtual Machine (JVM) unified
logging framework.
See \f[B]Enable Logging with the JVM Unified Logging Framework\f[R].
.RS
.RE
.TP
.B \f[CB]\-Xmixed\f[R]
Executes all bytecode by the interpreter except for hot methods, which
are compiled to native code.
On by default.
Use \f[CB]\-Xint\f[R] to switch off.
.RS
.RE
.TP
.B \f[CB]\-Xmn\f[R] \f[I]size\f[R]
Sets the initial and maximum size (in bytes) of the heap for the young
generation (nursery) in the generational collectors.
Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes,
\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or
\f[CB]G\f[R] to indicate gigabytes.
The young generation region of the heap is used for new objects.
GC is performed in this region more often than in other regions.
If the size for the young generation is too small, then a lot of minor
garbage collections are performed.
If the size is too large, then only full garbage collections are
performed, which can take a long time to complete.
It is recommended that you do not set the size for the young generation
for the G1 collector, and keep the size for the young generation greater
than 25% and less than 50% of the overall heap size for other
collectors.
The following examples show how to set the initial and maximum size of
young generation to 256 MB using various units:
.RS
.IP
.nf
\f[CB]
\-Xmn256m
\-Xmn262144k
\-Xmn268435456
\f[R]
.fi
.PP
Instead of the \f[CB]\-Xmn\f[R] option to set both the initial and maximum
size of the heap for the young generation, you can use
\f[CB]\-XX:NewSize\f[R] to set the initial size and
\f[CB]\-XX:MaxNewSize\f[R] to set the maximum size.
.RE
.TP
.B \f[CB]\-Xms\f[R] \f[I]size\f[R]
Sets the minimum and initial size (in bytes) of the heap.
This value must be a multiple of 1024 and greater than 1 MB.
Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes,
\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, \f[CB]g\f[R] or \f[CB]G\f[R]
to indicate gigabytes.
The following examples show how to set the size of allocated memory to 6
MB using various units:
.RS
.IP
.nf
\f[CB]
\-Xms6291456
\-Xms6144k
\-Xms6m
\f[R]
.fi
.PP
Instead of the \f[CB]\-Xms\f[R] option to set both the minimum and initial
size of the heap, you can use \f[CB]\-XX:MinHeapSize\f[R] to set the
minimum size and \f[CB]\-XX:InitialHeapSize\f[R] to set the initial size.
.PP
If you don\[aq]t set this option, the initial size is set as the sum of
the sizes allocated for the old generation and the young generation.
The initial size of the heap for the young generation can be set using
the \f[CB]\-Xmn\f[R] option or the \f[CB]\-XX:NewSize\f[R] option.
.RE
.TP
.B \f[CB]\-Xmx\f[R] \f[I]size\f[R]
Specifies the maximum size (in bytes) of the heap.
This value must be a multiple of 1024 and greater than 2 MB.
Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes,
\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or
\f[CB]G\f[R] to indicate gigabytes.
The default value is chosen at runtime based on system configuration.
For server deployments, \f[CB]\-Xms\f[R] and \f[CB]\-Xmx\f[R] are often set
to the same value.
The following examples show how to set the maximum allowed size of
allocated memory to 80 MB using various units:
.RS
.IP
.nf
\f[CB]
\-Xmx83886080
\-Xmx81920k
\-Xmx80m
\f[R]
.fi
.PP
The \f[CB]\-Xmx\f[R] option is equivalent to \f[CB]\-XX:MaxHeapSize\f[R].
.RE
.TP
.B \f[CB]\-Xnoclassgc\f[R]
Disables garbage collection (GC) of classes.
This can save some GC time, which shortens interruptions during the
application run.
When you specify \f[CB]\-Xnoclassgc\f[R] at startup, the class objects in
the application are left untouched during GC and are always be
considered live.
This can result in more memory being permanently occupied which, if not
used carefully, throws an out\-of\-memory exception.
.RS
.RE
.TP