Writing Your First Hello World in Java
Go Back to Course Outline I. Installing Java Development Kit (JDK) Download the Java Development Kit (JDK) from https://developers.r...
https://www.czetsuyatech.com/2019/12/java-hello-world.html
Go Back to Course Outline
I. Installing Java Development Kit (JDK)
- Download the Java Development Kit (JDK) from https://developers.redhat.com/products/openjdk/download. Select Java 8 as it is still the most widely supported version available. X64 (right-click on My Computer or This Computer and select properties) and MSI installer if applicable.
- I normally install JDK on c:\Java\Jdk\
folder. - https://en.wikipedia.org/wiki/Java_version_history
- Add Java into your user environment path.
- Make sure that there is no other entry of Java path in both your user and system path.
- Start a terminal and see if java and javac commands are running.
II. Set Java in User’s Environment Path
- Right-click on My Computer or This Computer.
- Click Advanced system settings.
- Click the Advanced tab.
- Click Environment Variable.
- You should arrive at the screenshot below.
- Create a new entry "JAVA_HOME" and set the path where you installed the JDK.
III. Downloading and Installing Eclipse
- Download eclipse from https://www.eclipse.org/downloads/
- Configure the installed JRE inside eclipse.
IV. Creating our First Hello World Project
- Inside eclipse select File / New / Java Project.
- In the Project name field enter Hello World.
- Select 1.8 in Use a project specific JRE.
- Click Finish.
V. Creating our First Hello World Project in Maven
- Inside eclipse select File / New / Other.
- In the select a wizard panel, Wizards filter, enter maven.
- Under the maven folder, select Maven Project. Click next.
- Click “Use default workspace location” or uncheck it to select a folder where you want the project to be created.
- You can also create and select a working set. Click next.
- In the new maven project panel, catalog selection, select Maven Central.
- Select the row with Group Id=org.apache.maven.archetypes, Artifact Id=maven-archetype-quickstart. Click next.
- Enter the following details:
- Group Id=com.broodcamp
- Artifact Id=hello-world2
- Package=com.czetsuya.hello
- Click finish.
VI. Compiling, Running and Debugging
- Run the application using the menu.
- Run / Run
- In the Run As a panel, select Java Application
- Select App, which is a class in our project
- Run the application using the project’s context menu.
- Right-click on the project
- Select Run As
- Select Java Application
- Select App, which is a class in our project
- Debug by selecting Run / Debug As / Java Application.
Post a Comment