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_NAMEinto the CMD and hitenter. - In order to compile your project to bytecode,
typejavac FILENAME.javaand, again, hitenter. - Now you have the
FILENAME.classin your folder at the desktop.
You can check this by typingdirinto 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.javafile by making aright-clickon 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 FILENAMEand 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
Advancedtab (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 clickit and clickEdit… - There should be a variable called
C:\Program Files\Javaor similar. Mine contained something with Oracle in it.Select itand clickBrowse… - Now, navigate to
C:\Program Files\Java\- select theBinfolder - hit 4 timesOK, once in each window. - In case your CMD is open,
closeandre-openit. You now can runjavac.