This repository contains Java learning resources and code examples for core concepts:
- Classes & Objects
- Static methods and variables
- Interfaces
- Enums
- Collections (Lists, Sets, Maps)
- Inner/Outer Classes
- Exception Handling, etc.
-
Clone this repo:
git clone https://github.com/Griffins2005/java-tutorials.git cd java-tutorials -
Compile all Java files in a package (example:
objectsclasses):javac objectsclasses/*.java -
Run the main class:
java objectsclasses.Main
Tip: Always compile before running, and make sure the package in the file matches the folder.
-
FileNotFound/ClassNotFound:
- Ensure the filename matches the class name (case-sensitive).
- Compile from the parent directory, not inside the package folder.
- Package name at the top matches the folder structure.
-
Extension errors (
.Java):- Use lowercase
.javaonly.
- Use lowercase
-
Syntax errors (
;expected, etc.):- Double-check every line ends with
; - Pay attention to curly braces
{ }and parentheses().
- Double-check every line ends with
-
Running classes without
mainmethod:- Only
java packagename.MainifMainhaspublic static void main(String[] args).
- Only
-
Changing packages or class names:
- Always refactor both filename and
package/classlines together.
- Always refactor both filename and
- Use
find . -name "*.class" -deleteto clean up old class files. - Use
javac packagename/*.javato batch-compile. - Use
java packagename.Mainto run the main class. - If you get errors, carefully read the first error message for hints.
Pull requests are welcome. For significant changes, open an issue first to discuss what you would like to change.
Happy coding!
Griffins Lelgut