The Java 10 JDK offers several command-line tools for developers to use. Here’s an overview of some useful tools and related features:
1. JShell (Interactive Java REPL)
The jshell
tool allows developers to experiment interactively by evaluating Java expressions, statements, and code snippets without the need to set up a complete program. It was introduced as part of JDK 9 but is also available in Java 10.
You can use JShell via:
- Command line: Just type
jshell
in your terminal/command prompt. - IntelliJ IDEA: Open the JShell console through Tools > JShell Console in the IDE. This allows trying smaller snippets of code and experimenting interactively [1].
2. Java Compiler (javac
)
The javac
tool is the standard way to compile Java source code into bytecode. In Java 10, the --release
flag can be used to ensure compatibility with earlier JDK releases.
Command:
javac --release <version> FileName.java
To compile your code:
- Open a terminal.
- Navigate to the directory containing the
.java
file. - Run the
javac
command followed by the file’s name.
3. Java Runner (java
)
The java
tool is used to execute compiled Java applications or scripts. Java 10 also supports temporary files and improved APIs for startup optimizations.
Command example:
java FileName
4. Java Flight Recorder and Other Tools
Java Flight Recorder is useful for profiling and analyzing runtime performance. In JDK 10, you need to enable UnlockCommercialFeatures
if using the Oracle JDK.
For example:
java -XX:+UnlockCommercialFeatures -XX:StartFlightRecording=duration=60s,filename=myrecording.jfr MyApplication
This is useful for monitoring or debugging [4].
5. JLink
The jlink
tool lets you create runtime images that include all the modules your application requires (introduced in JDK 9). With Java 10, improvements were made for better custom image creation.
Command example:
jlink --module-path <modules-path> --add-modules <module-name> --output <destination-folder>
This tool is handy when distributing lightweight application bundles. IDEs like IntelliJ IDEA also provide options to integrate it into Maven or Gradle builds [5].
6. Managing Executable Scripts
Create and run Java commands or files directly as scripts without needing to compile them. This concept started gaining traction with JDK 11’s “shebang” support but can also apply lightly to Java 10 for executable bundling purposes [6].
7. General IntelliJ IDEA Features for Java 10
IntelliJ IDEA helps users by automatically configuring and detecting Java 10 features, including modular programming. Several integrations for JDK tools like javac
, java
, and jlink
make development smoother [7].