How-To write your first Java program (without any IDE) short tutorial for Windows

Serhii Horoshko
2 min readJul 19, 2020
  1. Install Notepad++ https://notepad-plus-plus.org/downloads/
  2. Install JDK 11 from Oracle https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
  3. 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 and javac — version (you should restart cmd before check)
  1. Install git (check to install in cmd with command git — version) https://git-scm.com/downloads
  2. Registration on GitHub https://github.com/ and create a new empty repository (e.g. MyFirstProgram)
  3. Configure your git account
$ git config --global user.name "{%YOUR_FULL_NAME%}"
$ git config --global user.email "{%YOUR_EMAIL_ADDRESS%}"
  1. Install Gradle binary (copy it to the C:\) https://gradle.org/install/
  2. 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 — initialization
  • git checkout -b develop — create a new branch with name develop
  • git add . — add changes to the branch develop
  • git commit -m “Initial commit” — create commit
  • git remote add origin https://github.com/{%GITHUB_USERNAME%}/{%REPOSITORY_NAME%}.git
  1. Create SSH key: https://serhii-horoshko.medium.com/how-to-generate-your-ssh-key-798fdcf12722
  2. Add SSH key to your GitHub account in the Settings -> SSH keys -> New SSH keys
  3. Commit changes to the GitHub
git push origin develop
  1. 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

  1. Create .gitignore file in the project folder with >> .gitignore command and add to it build/ and .gradle text
  2. 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

Reference

  1. The Twelve Factors

--

--