Login Register






There was a very particular style of DDOS attack just now, it was mitigated.
Thread Rating:
  • 0 Vote(s) - 0 Average


[JAVA] A Basic Beginners Guide! filter_list
Author
Message
[JAVA] A Basic Beginners Guide! #2
A Basic Beginners Guide!


[Image: eclipse.png]
A little background on Java:
Code:
Java is a programming language originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. Java is a general-purpose, concurrent, class-based, object-oriented language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere". Java is currently one of the most popular programming languages in use, particularly for server-client web applications.
(Source:Wiki)

1.Java SE:
We need a Java Platform first, so we will download it from java.sun.com
The latest update is 6u26. Choose your Operating System and also make sure you download the correct xx-bit architecture. Ex: x86 or x64.
Download link

2. Eclipse:
Now we need a Compiler to execute and run our Java programs.
There are two most popular compilers, Netbeans and Eclipse. I prefer Eclipse.
I would recommend you to use Eclipse IDE for Java EE Developers. Again make sure you choose the correct xx-bit architecture.
Download Link

Installing and Running Guide:
1. Extract it and run the eclipse file(as Administrator).
Spoiler:
[Image: unledihw.png]

2. Click File>New Project>Name it whatever you want.
Spoiler:
[Image: unled1cw.png]


First Program(Hello World):
Strangely enough all programming languages starts with a Hello World program. So lets go ahead and type this.

Code:
public class 1337 {

    public static void main(String[] args) {
        System.out.println("Hello World");
    }

}

Explanation:
1. Public class:
Code:
Java classes contain fields and methods. A field is like a C++ data member, and a method is like a C++ member function.

Each field and method has an access level:

    private: accessible only in this class
    (package): accessible only in this package
    protected: accessible only in this package and in all subclasses of this class
    public: accessible everywhere this class is available

Similarly, each class has one of two possible access levels:

    (package): class objects can only be declared and manipulated by code in this package
    public: class objects can be declared and manipulated by code in any package
We mostly use public class for obvious reasons. You can use any name it doesnt matter.

2. public static void main(String[] args):
Code:
The public keyword is an access specifier, which allows the programmer to control the visibility of class members. When a class member is preceded by public, then that member may be accessed by code outside the class in which it is declared.In this case, main( ) must be declared as public, since it must be called by code outside of its class when the program is started. The keyword static allows main( ) to be called without having to instantiate a particular instance of the class. This is necessary since main( ) is called by the Java interpreter before any objects are made. The keyword void simply tells the compiler that main( ) does not return a value. As you will see, methods may also return values.
As stated, main( ) is the method called when a Java application begins. Keep in mind that Java is case-sensitive. Thus, Main is different from main. It is important to understand that the Java compiler will compile classes that do not contain a main( ) method. But the Java interpreter has no way to run these classes. So, if you had typed Main instead of main, the compiler would still compile your program. However, the Java interpreter would report an error because it would be unable to find the main( ) method.
Any information that you need to pass to a method is received by variables specified within the set of parentheses that follow the name of the method. These variables are called parameters. If there are no parameters required for a given method, you still need to include the empty parentheses. In main( ), there is only one parameter, albeit a complicated one. String args[ ] declares a parameter named args, which is an array of instances of the class String. Objects of type String store character strings. In this case, args receives any command-line arguments present when the program is executed.
You can again you anything instead of args, it doesnt matter.

3. System.out.println("Some Text")
Code:
System is a predefined class that provides acess to the system.
out is the outputstream that is connected to the console.
println() - Displays the String which is passed to it.

Output:
Spoiler:
[Image: unled3fu.png]


Note: The explanation part is taken from other resource to come with the best possible explanation but not ripped from any tutorial.
Spoiler:
[Image: unledbyds.png]

Reply





Messages In This Thread
[JAVA] A Basic Beginners Guide! - by 1337 - 07-13-2011, 06:00 PM
[JAVA] A Basic Beginners Guide! - by 1337 - 07-13-2011, 06:00 PM



Users browsing this thread: 1 Guest(s)






This forum uses Lukasz Tkacz MyBB addons.