Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

To Program in Java

Uploaded by

kentbar7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

To Program in Java

Uploaded by

kentbar7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

To program in Java, you need both an IDE (Integrated

Development Environment) and the JVM (Java Virtual


Machine). The IDE helps you write, edit, and manage
your code more efficiently, while the JVM allows your
Java applications to run on any device that has it installed,
providing platform independence.
Therefore JVM is platform independence.
Popular IDEs for Java include Eclipse, IntelliJ
IDEA, and NetBeans. Make sure you have the JDK (Java
Development Kit) installed as well, since it includes the
JVM and essential tools for compiling and running Java
applications.
Once we installed the Netbeans and JVM
Launch Netbeans
Windows: Click the Start menu, type "NetBeans," and
select the NetBeans IDE from the search results.
Alternatively, you can find it in your list of installed
programs.
Create or Open a Project:
 Once NetBeans is open, you can create a new project
by clicking on "File" > "New Project."
 To open an existing project, click on "File" > "Open
Project" and navigate to your project’s directory.

1 | P a g e The Java lab materials have been compiled by biniyam.


Start Coding: After creating or opening a project,
you can start writing your Java code.
The NetBeans IDE has four main components,
which are:
1. Editor: This is where you write and edit your code. It
supports syntax highlighting and code completion to
enhance productivity.
2. Output Window: This displays the results of your
program’s execution, error messages, and any other
output generated during the build and run processes.
3. Projects Window: This shows your project structure,
including files and folders, allowing you to manage
your project resources easily.
4. Navigator: This provides an overview of the
structure of your current file, such as classes,
methods, and variables, making it easier to navigate
through your code.

2 | P a g e The Java lab materials have been compiled by biniyam.


Editor

Output window

Project window

3 | P a g e The Java lab materials have been compiled by biniyam.


Navigator

4 | P a g e The Java lab materials have been compiled by biniyam.


Creating project step by step

5 | P a g e The Java lab materials have been compiled by biniyam.


Now it is time to create the package step by step

6 | P a g e The Java lab materials have been compiled by biniyam.


It is time to create a class step by step

7 | P a g e The Java lab materials have been compiled by biniyam.


8 | P a g e The Java lab materials have been compiled by biniyam.
9 | P a g e The Java lab materials have been compiled by biniyam.
Here are the code to create student class and account
class
public class Student {
//data
private int id;
private String name;
//the main method
public static void main(String[] args) {
System.out.println("hello world");
}
}
public class Account {
//data
private int balance;
private double accnum;
//method
public static void main(String[] args) {
System.out.println("account informaton ");
}}
10 | P a g e The Java lab materials have been compiled by biniyam.

You might also like