Hello guys! Thanks for all your views, I never really expected this blog to get more than 2. If you do not know, Minecraft is written using the programming language Java. Java is used on many operating systems and devices, even phones. This post will teach you how to display some text using Java. You will need to download a free editor. It is possible to do this without an editor and run it using Command Prompt, but you would have to modify system files and badly screw up your computer, and completely stop Java from working. So, lets get started!
First, you will need the editor. Go to www.eclipse.org and click on downloads on the top bar. Choose the Eclipse Standard. The current version is 4.3.1, but it will most likely be different when you try this. Download the .zip file, open it with an unzipping program, and extract the folder inside to your desktop. (Just click and drag.) The folder should be called "eclipse" with a lowercase E. Create another folder on your desktop and name it whatever you want. This is where all your project files will be stored.
You will need JDK, or the Java Development Kit if you want to code. The Java Development Kit is a set of files created by Oracle (the company that created Java) that allows you to program on your computer. You can get that here: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html Just click that you accept their Licence Agreement and choose your version from the uppermost box. Just follow the instructions for installation and you are ready to start programming!
Now open the eclipse folder and click on the icon (a purple circle) and Eclipse will start up. Wait for it to load, and when it asks for you to choose a workspace, browse to that folder you just created to store your files. After clicking ok, Eclipse will load some more, and you will be taken to a blank screen.
There may be a welcome message, there is on my version, just close that by clicking the X on the tab on the top of the screen. Now click on the File menu on the top left on the window, and go to New, and then Java Project. A window will open up, asking you to name your project. Give it a name, and don't touch anything else. After some loading, there should be a folder on the explorer on left side of the screen. Expand that folder, and there will be a folder named "src." Right click on that and go to New, and then Class. A lass in Java is compiled as a file that stores code in it. You can have multiple classes in a project, Minecraft has hundreds, but we will stick with 1 for this project. The new class window will pop up. Give it a name, and check the box that says public static void main(String[] args) That is the main method. A method is a group of code that is enclosed with brackets{} that you can call at any time to prevent repeated code. The main method is the code that is executed when the program is run. If a method is created but not called for, the code in that method will not be run. We will only deal with the main method for this basic tutorial.
After the class is created, you will see the public class line at the top, and then the method line after that. All of those have brackets, so anything you type between the public class brackets will be inside that class but not the main method. The main method is inside the public class, so any code in the main method is also in the class.
In the main method brackets, type the following code:
System.out.println("Hello World!");
The code is case sensitive, so make sure the S is capitalized. The Hello World is not, however, because that is how it is going to be displayed. The System part tells you that it is well, the system that doing something. Out means that it is output. Println will print in the console, whatever is after it. The words to be displayed must be in quotes inside parentheses. The ; at the end of the line tells you that that code is complete. println will create a new line to print it, so you can do System.out.print("Hello World!") to display it on the current line on the console. You are now finished! If anything doesn't work, just compare your code with the one below it. Be aware that any words after a // are comments and will not affect the code in any way. Click the green arrow button at the top of the screen, and it will ask you if you want to save. Click ok and it should say "Hello World!" in the console at the bottom of the screen.
Correct Code:
public class ClassName {
//TODO Auto-generated method stub
System.out.println("Hello World!");
}
}
If you want to learn more Java, go to www.java-made.easy.com/
That is where I learned basic programming. It is very helpful and doesn't use technical terms that confuse you.
If you would like to check out the Youtube Channel associated with this Blog, go here. http://www.youtube.com/channel/UCbhXCHfeJAHbw8AhKdBS7lQ
No comments:
Post a Comment