Introducción a Java
Your first step into the world of programming with Java
What is Java?
Java is a general-purpose, object-oriented programming language designed to have as few implementation dependencies as possible.
Object-Oriented
Everything in Java is an object, which makes organizing code easier.
Cross-platform
Write once, run anywhere (WORA).
Safe and Robust
Exception handling and compile-time type checking.
High Performance
Just-In-Time (JIT) compilation for optimization.
Java Architecture
Java Application
1// Your Java codepublic class MiApp {
public static void main(String[] args) {
System.out.println("Hola Mundo");
}
}
JDK (Java Development Kit)
2JVM (Java Virtual Machine)
3Operating System
4JDK (Development Kit)
Tools to develop Java applications
- Compiler (javac)
- Debugger
- Documentation
- Libraries
JRE (Runtime Environment)
Required to run Java applications
- JVM (Virtual Machine)
- Standard libraries
- Plugins
JVM (Virtual Machine)
Runs Java bytecode
- Interprets bytecode
- Manages memory
- Provides security
Installing Java
Download JDK
Visit the official Oracle page or use OpenJDK:
Select your operating system:
Instructions for Windows:
- Download the .exe installer
- Run the installer as administrator
- Follow the installation wizard
- Use the default path:
C:\Program Files\Java\
Installation Process
Follow these steps to complete the installation:
Run Installer
Double-click the downloaded file
Accept Terms
Accept the license agreement
Select Path
Use the recommended default path
Wait for Installation
The process may take a few minutes
Configure Environment Variables
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode)
Manual configuration (Windows):
- Search for "Environment Variables" in the start menu
- Click on "Environment Variables"
- Under "System variables", click "New"
- Name:
JAVA_HOME - Value:
C:\Program Files\Java\jdk-17 - Edit the "Path" variable and add:
%JAVA_HOME%\bin
Verify Installation
Test your installation:
Test code:
public class VerificarJava {
public static void main(String[] args) {
System.out.println("✅ Java instalado correctamente");
System.out.println("Versión: " + System.getProperty("java.version"));
System.out.println("Directorio: " + System.getProperty("java.home"));
}
}
Your First Java Program
Java Code Editor
2
3
4
5
6
7
8
9
10
Result:
Compile and run to see the result
Code explanation:
Defines a public class named HolaMundo
Main method where execution begins
Prints text to the console
Comments to explain the code
Anatomy of a Java Program
public class MiClase {
public static void main(String[] args) {
// Instrucciones aquí System.out.println("Hola Java");
}
}
Select a part for explanation:
Class Declaration
In Java, all code must be inside a class.
public: The class is accessible from anywhereclass: Keyword to define a classMiClase: Name of the class (must match the file name)
Main Method
Entry point of any Java program.
public: Accessible from outside the classstatic: Can be called without creating an objectvoid: Does not return any valueString[] args: Command-line arguments
Program Body
Contains the statements that get executed.
- Statements end with
; - They run in order from top to bottom
- Comments are ignored (// or /* */)
Syntax Rules
- Java is case-sensitive
- Class names must start with an uppercase letter
- The file name must match the class name
- Use
.javaas extension - Braces
{}delimit code blocks
Development Tools
Choose a development environment:
Visual Studio Code
Recommended for beginners
✅ Advantages
- Free and open-source
- Extensive extensions
- Light and fast
- Multi-language
❌ Disadvantages
- Requires configuration
- Less pure Java integration
- Additional extensions required
Basic setup:
- Install VS Code from its website
- Open the Extensions tab (Ctrl+Shift+X)
- Search for and install "Extension Pack for Java"
- Restart VS Code
Practice with This Game
Build the Java Program
Drag the pieces to build a correct Java program:
public class Programa {
public static void main(String[] args) {
System.out.println("¡Funciona!");
}
echo "Hola Mundo";
print("Java");
}
Summary and Next Steps
What you learned
- What Java is and its main features
- Java architecture (JDK, JRE, JVM)
- Environment installation and setup
- Basic structure of a Java program
- Your first "Hello World!"
Next steps
- Variables and data types
- Operators and expressions
- Control structures
- Methods and functions
- Introduction to OOP
Learning tips
- Practice every day, even if just 30 minutes
- Modify the examples to understand how they work
- Don't copy and paste, write the code yourself
- Join programmer communities
- Build small personal projects