An overview, sorted by topics, of the projects and learning tasks that I have worked on, or am still working on, towards learning the fundamentions of Java. These were mainly written during courses at JetBrains Adademy Hyperskill. Among them, however, is also code that I wrote in the course of tutorials from other sources, such as YouTube, Reddit or other platforms.
At this point I assume you already have installed the JDK (Java Development Kit), as well as the JRE (Java Runtime Environment). In case there is one of them missing, you can get both here:
- Download all Java files related to the program you are intending to run in
a new folder on your desktop.
- Open Windows start menu, type CMD and run it.
- The standard directory you are currently in is usually
C:\Users\YOUR_USERNAME
(on Win10 at least). - Navigate to the folder you created previously, type
cd Desktop\FOLDER_NAME
into the CMD and hitenter
. - In order to compile your project to bytecode,
typejavac FILENAME.java
and, again, hitenter
. - Now you have the
FILENAME.class
in your folder at the desktop.
You can check this by typingdir
into CMD, followed byenter
.
This lists all files inside that folder.
- For the program to be executed, you need to run the file containing the
main method
. To do so, you either open each.java
file by making aright-click
on the file, chooseOpen with...
, selectNotepad
. Now look in the first couple of code for a line calledpublic static void main(String[] args) {
. - Too complicated? I've got your back!
Alternatively, you may just run one file after another until you found the correct file ;) - Since you should still be in your folder on the desktop (see step 1#),
just enter
java FILENAME
and hitenter
.
Unable to run javac
or PATH
entry / Environment Variable
is missing.
To fix this, open
Windows start menu and type environ
, this should be
enough to bring up Edit the system environment variables
- run it.
- Go to the
Advanced
tab (top side) and clickEnvironment Variables…
- In the lower part of the upcoming window, you find the
System variables
, look for the entry namedPath
(take care, there is another entry with a similar name),highlight / single click
it and clickEdit…
- There should be a variable called
C:\Program Files\Java
or similar. Mine contained something with Oracle in it.Select it
and clickBrowse…
- Now, navigate to
C:\Program Files\Java\
- select theBin
folder - hit 4 timesOK
, once in each window. - In case your CMD is open,
close
andre-open
it. You now can runjavac
.