How-To write your first Java program (without any IDE) short tutorial for Windows
2 min readJul 19, 2020
- Install Notepad++ https://notepad-plus-plus.org/downloads/
- Install JDK 11 from Oracle https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
- Configure Java 11 in the System Variable in Path (for check Java installation write in cmd:
where java
)
- variable:
%JAVA_HOME%
value:C:\Program Files\Java\jdk-11.0.11
%JAVA_HOME%\bin
in Path- check to install in cmd with the command
java — version
andjavac — version
(you should restart cmd before check)
- Install git (check to install in cmd with command
git — version
) https://git-scm.com/downloads - Registration on GitHub https://github.com/ and create a new empty repository (e.g. MyFirstProgram)
- Configure your git account
$ git config --global user.name "{%YOUR_FULL_NAME%}"
$ git config --global user.email "{%YOUR_EMAIL_ADDRESS%}"
- Install Gradle binary (copy it to the C:\) https://gradle.org/install/
- Configure Gradle in the System Variable in Path. In Path
C:\{%GRADLE_FOLDER_NAME%}\bin
(e.g.C:\gradle-7.0\bin
)
Write code in Notepad++ and save it with .java file type
public class MyFirstProgram {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Create Project folder
- First:
{%PROJECT_NAME%}sandbox\src\main\java
move your code here - Second:
{%PROJECT_NAME%}sandbox\src\test\java
Initialization git in the {%PROJECT_NAME%}
folder
git init
— initializationgit checkout -b develop
— create a new branch with name developgit add .
— add changes to the branch developgit commit -m “Initial commit”
— create commitgit remote add origin https://github.com/{%GITHUB_USERNAME%}/{%REPOSITORY_NAME%}.git
- Create SSH key: https://serhii-horoshko.medium.com/how-to-generate-your-ssh-key-798fdcf12722
- Add SSH key to your GitHub account in the Settings -> SSH keys -> New SSH keys
- Commit changes to the GitHub
git push origin develop
- Add Gradle
build.gradle
file to the project and configure it (create it with command>> build.gradle
) and add:
apply plugin: 'java'
apply plugin: 'application'
mainClassName = "MyFirstProgram"
Run gradle build
, run gradle run
command
- Create
.gitignore
file in the project folder with>> .gitignore
command and add to itbuild/
and.gradle
text - Commit changes to GitHub (check the status with
git status
)
git add .
git commit -m “Added gradle to the project, added .gitignore file”
git push origin develop
git log
— check commits with command- check status with
git status
command