Minecraft Blogs / Tutorial

Java Text Tutorial 2 - Setting up a project

  • 225 views, 1 today
  • 1
  • 0
Cool_Man7's Avatar Cool_Man7
Level 16 : Journeyman Modder
9
And we're back! Welcome to episode 2 of Java Text Tutorials!


Table of Contents:
2. Setting up a Project
     2.1 Setting up a class
     2.2 Hello PlanetMinecraft

2. Setting up a Project
A side note from the last tutorial. If you're clueless how to close the Welcome window.
undefined
This should be the same for all eclipse versions. Make sure you have the Java version though. JavaEE will work but the Java one is better.

Now to actually code. First thing you need is a project.
Click File < New < JavaProject.
undefined
A window will pop up. This may look confusing at first but we only need to change a few things. Enter a name for your project. I will call mine "PlanetMinecraft". You can call it whatever you like. Then you need to set what java version you will be working in. This depends on what JavaSDK you got. If you have 1.8 then you go to the Use an execution enviroment JRE dropdown and choose JavaSE-1.8. And the same with the rest. Note you need to have that java version to use it. You can't use a JavaSDK version 1.8 with JavaSE 1.7. I will be using 1.7. When you are done it should look similar to this:
undefined
Click Finish and the project will create itself!

2.1 Setting up a class
This is an easy one. Right click on the new project you just created and click New < Class. A couple of things will be desirable to change here. First would be a package. Naming packages can be based on someones preference. I prefer to name mine com.myname.projectname. Replacing each of them with their appropriate names. For the name of class I will just call it Tutorial.
And finally, make sure the public static void main(String[] args) checkbox is checked. This will keep us from typing it later on. Here is our class setup:
undefined
Click Finish and our new class will be made!

2.2 Hello PlanetMinecraft
This will just be a simple println statement. But it will be a very simple println statement. If you're not sure what that is I'll explain in a second. Delete the line that says "// TODO Auto generated method stub"
Make sure you are typing inside of the public static void main method that was created. Type this:
System.out.println("Hello PlanetMinecraft");
Type EXACTLY that and make sure it is in the public static void main curly brackets that look like this {   }
What this is saying is that the System will print out a new statement based off of what is in the parenthesis. It should look similar to this:
undefined
Now hit the run button on your IDE. In eclipse it look like this:
undefined
It is the the top toolbar. Click on it. If it asks you to save hit yes. Then a console window will open up at the bottom of eclipse and it will display this:
undefined
And there you have it! You have created your first java program! Only you can actually see it though. You have to have eclipse open to do this so don't go trying to make a game with this. We will get to that point.

In the next tutorial we will talk about variables and strings.
CreditImage From Oracle(www.oracle.com)
Tags

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome