Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Java Chapter 1 - Basics filter_list
Author
Message
Java Chapter 1 - Basics #1
What is Java.
Java is an object oriented programming language, which was designed by James Gosling at Sun Microsystems in 1995. This language is mostly based on C/C++, but it is still less powerful than either of them. You can run Java program on any OS.
A Java program is called source code and the JVM [Java Virtual Machine] is responsible for the conversion of the source code into Bytecode [classfile].
Java is one of the most popular programming language, why?
1. Write once run anywhere.
2. You can create powerful web apps.
3. You can develop server side apps for forums.
4. Java has the MOST open source library to choose from.
Etc.
Hence, in Java all source code of a program is first written and is saved in text form, then the Java compiler [javac] does its job by converting the source code into object code or Bytecode as class file, after that JVM runs the class file containing the Bytecode and as we know that JVM is available on many OS's so virtually a .class file can be run on almost any operating system.
So, if you hand the same Java Bytecode file to a Macintosh, then the Macintosh JVM interprets that same Bytecode for the Mac environment and if you hand the bytecode to Windows then Windows JVM will interpret it for Windows environment.

Getting Your Computer Ready To Write Java Programs.
To start writing Java programs we need some tools to get started, those are:

1. Java compiler.
2. Java Virtual Machine.
3. Java API
4. Access to the Java API documentation.
5. An editor to compose your Java programs. You can use WordPad or notepad but we are going to use an IDE.

-->For the first 4 things we just need Java SDK which can be downloaded from here:-
http://www.oracle.com/technetwork/java/j...80260.html
Choose your flavor and system type(32bit or 64bit) and then download and install.

-->For editing the programs we will use an Integrated development environment or IDE, we are going to use IDE because it’s a better way to write Java programs. Here are some reasons why it’s preferred way of making Java Programs.
• It divides your screen into many panes so that you can edit, issue commands and test the programs with an ease.
• You can customize the panes for quick access.
• Run, Debug and compile your program with just a click.

There are a lot of IDE’s but I am going to use Netbeans IDE, you can use another one called Eclipse.
Download:
Netbeans:
https://netbeans.org/downloads/index.html
Eclipse:
http://www.eclipse.org/downloads/
NOTE: If you are downloading 64bit java then download the 64bit version of IDE, same goes for 32bit.



Installing IDE and Running a Simple Java Program
Now, after installing your favorite IDE, open it.

Run Your First Program.
Step1: Click on “File” on the menu bar and then click on “New Project”

Step2: For the categories select “Java” and Projects select “Java Application” and click on Next.

Step3: Now enter “Project Name” and click on finish.

Step4: Now, you will see the project pane populated and the source code pane will have the source file “you-project-name.java” opened.

Step5: After the following code:-
public static void main(String[] args) {
add:-
System.out.println(“Hello World”);
And then run your program, if you see “Hello World” printed in the output pane, then the IDE works. And yes I forgot to add that Java like C is a case sensitive language so in Java a is not equal to A. So, watch out for cases.

Some Terms in Java Programs
Now, we are going to talk about some important terms in our java program, those are Package and Classes. We will talk about System.out.println(); in next chapter and public static void main(String[] args) in further chapters.

Package:

The group of types like classes, interfaces, enumerations and annotations is called package, in short it contains all the files related to your programs.Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier etc.
Some of the existing packages in Java are:
• java.lang - bundles the fundamental classes
• java.io - classes for input , output functions are bundled in this package
Also, programmers can create their own classes. Since the package creates a new namespace there won't be any name conflicts with names in other packages. Using packages, it is easier to provide access control and it is also easier to locate the related classed.
Classes
Java class file is a file (with the .class filename extension) containing a Java bytecode which can be executed on the Java Virtual Machine (JVM). As mentioned earlier it is generated by javac from the .java file or your program’s source code.

Important Points
1. A Java program can be run on any platform, since it is Write once run anywhere.
2. A Java program is first converted into Bytecode (object code) by JVM and then is run on the computer.
3. Package is a group of related types like classes, interfaces, enumerations and annotations.
4. Java Class file contain the Bytecode generated by the Java virtual machine.
5. I recommend you to remember the following line:-
package packagename;
public class packagename {
public static void main(String[] args) {

}
}
In case IDE is not available, it will be very useful.
[Image: znALY5V.jpg]

Reply

RE: Java Chapter 1 - Basics #2
Did you write this? or did someone from thescience.info write it?

Reply

RE: Java Chapter 1 - Basics #3
Now this is a perfect thread. Informative, detailed, easy to understand, good job (or good find?)
[Image: BAvhP6h.png]
Code:
[5:42:25 PM] i0xillusi0n: Breshie don't bust a nut over chloe now
[5:42:31 PM] Entity: fapfapfapfapfapfapfapfapfapfap
[5:42:33 PM] Jigglypuff | SL: EWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

Reply

RE: Java Chapter 1 - Basics #4
(06-19-2013, 09:44 PM)Earthly Minds Wrote: Did you write this? or did someone from thescience.info write it?

I wrote this with some help of a friend from TheScience.
[Image: znALY5V.jpg]

Reply

RE: Java Chapter 1 - Basics #5
Needs less copy pasta, and why do you even bother trying to learn java, it's a terrible fucking language.

Reply

RE: Java Chapter 1 - Basics #6
(06-20-2013, 05:28 AM)better_than_you Wrote: Needs less copy pasta, and why do you even bother trying to learn java, it's a terrible fucking language.

I don't want to be rude but have you ever heard of Android Software Development?
I "think" it's totally based on Java and further, I "think" that Java is one of the most demanding programming language.

and what's copy pasta?
[Image: znALY5V.jpg]

Reply

RE: Java Chapter 1 - Basics #7
(06-20-2013, 01:59 PM)§herlock Wrote: I don't want to be rude but have you ever heard of Android Software Development?
I "think" it's totally based on Java and further, I "think" that Java is one of the most demanding programming language.

and what's copy pasta?

copy pasta means he's saying you copy pasted the tutorial.
[Image: BAvhP6h.png]
Code:
[5:42:25 PM] i0xillusi0n: Breshie don't bust a nut over chloe now
[5:42:31 PM] Entity: fapfapfapfapfapfapfapfapfapfap
[5:42:33 PM] Jigglypuff | SL: EWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

Reply

RE: Java Chapter 1 - Basics #8
(06-20-2013, 01:59 PM)§herlock Wrote: I don't want to be rude but have you ever heard of Android Software Development?
I "think" it's totally based on Java and further, I "think" that Java is one of the most demanding programming language.

and what's copy pasta?

It's only based on Java if you want it to be, you can program an android app in any language.

How on earth is Java the most demanding? Do you even know how to write a function to accept input without java spoonfeeding you?

Reply

RE: Java Chapter 1 - Basics #9
(06-20-2013, 07:06 PM)i0xIllusi0n Wrote: copy pasta means he's saying you copy pasted the tutorial.

In that case I will need the link from where the tutorial is copied.

(06-20-2013, 07:14 PM)w00t Wrote: It's only based on Java if you want it to be, you can program an android app in any language.

How on earth is Java the most demanding? Do you even know how to write a function to accept input without java spoonfeeding you?

It's only based on Java if you want it to be, you can program an android app in any language.
Who the hell told you that? Java is the primary android development language, C and C++ NDK for libraries but not apps and Python, bash, et. al. - Via the Scripting Environment.Android is highly dependent on it's java architecture and I don;t think there is any other primary development language. In case you can then I would be delighted to see that.


How on earth is Java the most demanding?
I don't know how you all think but here's why java is important:-

1.Write software on one platform and run it on virtually any other platform (WORA).
2.Create powerful web application and games [ever heard of runescape?].
3.You can develop server side apps for forums.
4.Combine applications or services using the Java language to create highly customized applications or services
5.Write powerful and efficient applications for mobile phones[some mobile phones are still based on java only] , remote processors, low-cost consumer products, and practically any other device with a digital heartbeat
6. Java has the MOST open source library to choose from.
There is much more.

Do you even know how to write a function to accept input without java spoonfeeding you?
Do you know how?


Further, I am not saying that you must learn only Java. I will post other languages too.
(This post was last modified: 06-21-2013, 04:55 AM by §herlock.)
[Image: znALY5V.jpg]

Reply

RE: Java Chapter 1 - Basics #10
Yes, I do. I can do it in ASM. Can you? Do you even know how to optimize a program? Or what a buffer is? A pointer?

I can do all of your wonderful bullet points in a handful of other languages that aren't shit as well.


And for your challenge...
That was easy.

Reply







Users browsing this thread: 1 Guest(s)