How to do Java Programs in Debian
1. Install Java Development Kit (JDK)
First, ensure you have the JDK installed. You can install it using the package manager:
sudo apt update
sudo apt install default-jdk
2. Verify the Installation
Check if Java is installed correctly:
java -version
3. Write the Java Program
Create a directory for your Java program and navigate to it:sh
mkdir /java_programs cd /java_programs
Create a file named HelloWorld.java using your preferred text editor (e.g., nano, vim,edit )
gedit HelloWorld.java
Add the following code to the file:
public class HelloWorld {
public static void main(String[] args)
{
System.out.println("Hello, World!");
}
}
Save the file and exit the text editor.
Save the file and exit the text editor.
4. Compile the Java Program
Compile the Java program using the javac command:
javac HelloWorld.java
Run the compiled Java program using the java command:
java HelloWorld
You should see the output:
Hello, World!Naming Conventions
Comments
Post a Comment