Getting the JDK
On Ubuntu/Debian
$ sudo apt install openjdk-8-jre
On Fedora/CentOS:
$ su - "yum install java-1.8.0-openjdk"
On Windows, visit jdk.java.net.
Install Eclipse
- download from eclipse.org.
- extract files from the
eclipse-inst-(platform).tar.gz
file. - into the
eclipse-installer
folder run theeclipse-inst
file. - check for the advanced mode if you want to tune your eclipse installation.
Set default Java version (linux)
Use the command alternatives
:
$ sudo alternatives --config java
[sudo] password for user:
There are 3 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181.b15-6.fc28.x86_64/jre/bin/java)
2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.1.13-1.fc28.x86_64/bin/java)
*+ 3 java-9-openjdk.x86_64 (/usr/lib/jvm/java-9-openjdk-9.0.4.11-6.fc28.x86_64/bin/java)
Enter to keep the current selection[+], or type selection number:
and choose the version you need.
The java command options
# to launch a class file:
java [options] mainclass [args ...]
# to launch a mainclass in a JAR file:
java [options] -jar jarfile [args ...]
# to launch the main class in a module:
java [options] -m module[/mainclass] [args ...]
# or
--module module[/mainclass] [args ...]
# to launch a single source-file program:
java [options] source-file [args ...]
Options
-Dproperty=value
Sets a system property value. The property variable is a string with no spaces that
represents the name of the property. The value variable is a string that represents
the value of the property. If value is a string with spaces, then enclose it in
quotation marks
(example -Dfile.encoding=UTF8
-Xmx size
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 k or K to indicate kilobytes, m or M
to indicate megabytes, or g or G to indicate gigabytes. The default value is chosen
at runtime based on system configuration. For server deployments, -Xms and -Xmx
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:
-Xmx83886080
-Xmx81920k
-Xmx80m
-Xss size
Sets the thread stack size (in bytes). Append the letter k or K to indicate KB, m
or M to indicate MB, or g or G to indicate GB. The default value depends on the
platform:
- Linux/x64 (64-bit): 1024 KB
- macOS (64-bit): 1024 KB
- Oracle Solaris (64-bit): 1024 KB
- Windows: The default value depends on virtual memory
The following examples set the thread stack size to 1024 KB in different units:
-Xss1m
-Xss1024k
-Xss1048576
--
Advanced Garbage Collection Options for Java:
-XX:(option)