
Code-on-Blog wishes you a very merry Christmas !
Code-on-Blog has the simple task to teach you some stuff about programming.You will learn about programming languages such as Java, C++, Python and others.Learn some Linux tips and tricks in order to take advantage of its unique features! Hope this Code-on-Blog will help you !
First download and install tha Java development Kit from here : http://java.sun.com/javase/downloads/index.jsp
Make sure you installed it right like this :Click Start->run
Then write "cmd" and press enter. In the console window write "java -version" and press enter again. If you don't get an error then you made the first step :).
Download and install an IDE(Integrated Development Environment) or simpler : "the program where you write the code".Here are some choices :
Eclipse (big IDE written in java)-it's great but it's pretty big so you need a strong computer for it. Take it from here :http://www.eclipse.org/
Netbeans(big IDE written in java)-same as at Eclipse. You might have installed the JDK with bounded with this one. If not get it from here : http://www.netbeans.org/
JCreator(written in C++)-small and fast.It's a commercial software but you can install the free version of it. It's more than enough for beginning.Here it is : http://jcreator.com/
Now create a file called HelloWorld.java ,open it from the IDE and copy this code there :
public class HelloWorld{
public static void main( String[] args ){
System.out.println( "Hello world" );
}
} Save it. Now you might be able to compile and run it. If you are not then you might need to configure your IDE or just use the command line mode of compiling.
Place your file in a directory (lets say c:\java\source\).
Open a command prompt (Start->run+"cmd" +Enter,remember ? :) )
Write :
cd c:\java\source
"c:\Program Files\jdk1.6.0_03\bin\javac" HelloWorld.java
You might need to change the your path ( c:\Program Files\jdk1.6.0_03\ ) to where the jdk is installed.
Now you just compiled your first java program. All you have to do now is run it .In the same console window write :
java HelloWorld
(must be HelloWorld not HelloWorld.java)
This will output Hello World !
Congratulations you just finished your first java program.
Now try to change your source code then save,compile and run to see what happens.
Change this
System.out.println( "Hello world" );to
System.out.println( "The text changed :) " );run it.
Try this then.
System.out.println( "Hello "+"World !"); Then change it to this
System.out.println( "1+3="+(1+3) ); That's all. Hope you enjoyed it !
Write once, run everywhere !Many know what java is . If you don't there's no need to panic. You will soon learn the concept of java.
Java is a programming language released in 1995 by Sun Microsystems . Most of it's syntax derives from C and C++ but is a higher level programming language.Higher level doesn't mean that it's better,it only means that it's used for things such as desktop,web applications , not for programming drivers or operating systems such as Windows and Linux . Java applications are compiled to bytecode which can run on any Java virtual machine (JVM) regardless of the operating system or computer architecture.
Java is not as fast as C++(because C++ is a compiled language) , but is not as slow as python (because python is an interpreted language) . The advantage of using it over faster languages is that it's syntax is very clear, it is an Object Oriented Programming (OOP) language, it's fast enough to be used in most cases, It's mostly PORTABLE (big advantage in some cases) and because you won't have to deal with low level stuff, the time required to develop an application is greatly reduced.
I already said too much so the next post will teach you how to write a simple program in java.