This README keeps my personal notes from the PluralSight course Setting up a Java Development Environment by __
You write code in java files (Hello.java
). This code is compiled with javac
into class files (Hello.class
) which is byte code.
The class files can be executed with the java
command.
Actually, the java
command calls the Java Virtual Machine (JVM)
and the Java Standard Edition (SE) APIs
.
The combination of java
and javac
is called the JDK
for Java Development Kit
.
- Download the latest JDK: <jdk.java.net>
- Extract the zip file into the
C:\Program files
directory. - Change the systemd variables: add
JAVA_HOME -> C:\Program Files\jdk
and updatePath -> C:\Program File\jdk\bin
. - Open a cmd and type
java --version
to make sure.
- Donwload IntelliJ and install it.
- Create new project
- Add a
Java Class
namedcom.github.marcoandre1.Main
to thesrc
folder (which creates acom.github.marcoandre1.Main.java
file). - Add a second
Java Class
namedcom.github.marcoandre1.TitlecaseConverter
to thesrc
folder.
- Select both classes and right click on
Refactor
and choseMove Classes...
. - To package
com.example
(It is common use, to choose your reverse website for example). - Click on
Refactor
. com.github.marcoandre1.Main
andcom.github.marcoandre1.TitlecaseConverter
are now in thecom.example
package.
- Java applications are packaged into
JAR
files (forJava ARchive
) which are basicallyzip
files (you can unzip it). - A
jar
file contains the packages and a manifest. - Add a
TC-MANIFEST.MF
file with the following content:com.github.marcoandre1.Main-Class: com.example.com.github.marcoandre1.Main
- Create a
jar
file:jar cvmf TC-MANIFEST.MF com.github.marcoandre1.TitlecaseConverter.jar .
- Run the
jar
file with the following command:java -jar com.github.marcoandre1.TitlecaseConverter.jar
.
File
menu ->Project structure...
Artifacts
->+
->JAR
->From modules with dependencies...
- Choose
com.github.marcoandre1.Main Class
->OK
- Check
Include in project build
andOK
- Build and
jar
file should be inout
folder.