Welcome to Java Programming
Hi and welcome to java programming here you can learn all about the java programming language. Lets start java programming, first you will need a few things first download the latest java JDK SE from Oracle here.
Now you have downloaded and installed the JDK SE you now have to set the environment. (if you are unsure on how to do this please ask someone who knows how to do this, or look on YouTube under java.) first on you computer goto Control Panel-->System-->Advanced system settings-->Environment Varibles. Once you are at environment variables, click on the New.. button under the users variables under variable name type "path" (without quotes) then under the variables value enter the path of the JDK's bin folder e.g. C:\Program Files\Java\jdk1.6.0_21\bin now you've setup you java development environment.
Now lets get started with the code first open a text editor of any kind like Notepad or Word, I use Notepad++ which you can download here which allows you which programming language that you are using. Now copy the following.
//Java programming code
class MyFirstClass { //all java files must have a class in them
public static void main(String args[]) { //a java project must have at least 1 main
System.out.print("Hello, World!");
}
}
After copying that code save that file as a .java e.g. app.java, next open the command prompt and make sure the path is the same path where you saved the java file and type javac then the name of the file you just created e.g. javac app.java then if there are no errors it will compile the java file into a .class file. Now type java then the name of the class in the code e.g. java MyFirstClass the command prompt will run the file you just compiled. The output will be shown in the window.
Getting a better programming evironment
Using the command prompt for java development is not the most efficent way to complie java code so lets download a IDE (Intergrated Development Evironment) first goto netbeans.org and download the Java SE Netbeans IDE. Go through the installation screens, now Netbeans has been installed you can now develop Java GUI applications with a drag and drop interface. The IDE also helps to debug any errors that may occur in your code and help with the coding process by suggesting code snippets from the intellisense.
Now you have downloaded and installed the JDK SE you now have to set the environment. (if you are unsure on how to do this please ask someone who knows how to do this, or look on YouTube under java.) first on you computer goto Control Panel-->System-->Advanced system settings-->Environment Varibles. Once you are at environment variables, click on the New.. button under the users variables under variable name type "path" (without quotes) then under the variables value enter the path of the JDK's bin folder e.g. C:\Program Files\Java\jdk1.6.0_21\bin now you've setup you java development environment.
Now lets get started with the code first open a text editor of any kind like Notepad or Word, I use Notepad++ which you can download here which allows you which programming language that you are using. Now copy the following.
//Java programming code
class MyFirstClass { //all java files must have a class in them
public static void main(String args[]) { //a java project must have at least 1 main
System.out.print("Hello, World!");
}
}
After copying that code save that file as a .java e.g. app.java, next open the command prompt and make sure the path is the same path where you saved the java file and type javac then the name of the file you just created e.g. javac app.java then if there are no errors it will compile the java file into a .class file. Now type java then the name of the class in the code e.g. java MyFirstClass the command prompt will run the file you just compiled. The output will be shown in the window.
Getting a better programming evironment
Using the command prompt for java development is not the most efficent way to complie java code so lets download a IDE (Intergrated Development Evironment) first goto netbeans.org and download the Java SE Netbeans IDE. Go through the installation screens, now Netbeans has been installed you can now develop Java GUI applications with a drag and drop interface. The IDE also helps to debug any errors that may occur in your code and help with the coding process by suggesting code snippets from the intellisense.