Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Thursday, August 8, 2013

Part 2  Start with part 1 is very understand

Introduction Fundamentals of Java quickly became easier with Intecs. This site is for Java programmers who want to use the Java programming language to create applications using the basics of Java. This site is for beginners and for advanced Java programmers that do not require prerequisite knowledge of Java. To start using Java you must have a basic understanding of programming concepts.



After going through all the tutorials on this site, you should learn the basic concepts and features of the Java programming language, including exceptions, swing GUI programming, under Collections etc. A lot of code examples used throughout exercise to better understand the language.
All advertisements and programs on this site are compiled and run with JDK .

Download : JDK and JRE 

Java Architecture

The Java environment consists of a number of system components. You can use these components at compile time to create the Java program at runtime to execute the program. Java achieves its independence with the creation of programs designed to run on the Java virtual machine, rather than any specific computer system.

  • After writing a Java program, you are using a compiler that reads the instructions in the program and translated into a machine-independent format called bytecode.
  • Bytecode files, which are very compact, easily transported through a distributed system such as the Internet.
  • The compiled Java code (code resulting byte) will be executed at run time.

Java programs can be written and executed in two ways:

  • Stand-alone application (a Java Swing)
  • Applet that runs in a web browser (eg Internet Explorer)



Java source code

A Java program is a set of one or more Java classes. A Java source file can contain more than one class definition and has an extension of Java .. Each class definition in the source file is compiled into a separate class file. The name of the compiled file consists of the name of the class. Class as an extension. Before proceeding further in this section, I suggest you go through the "basic elements of the following languages.

Below is an example of Java code for the traditional Hello World program. In essence, the idea behind this Hello World program is to learn how to create a program, compile and run. To create the Java source code you can use any editor (pad / Edit Plus text are my favorite), or you can use an IDE like Eclipse.

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}//End of main
}//End of HelloWorld Class

Output
Hello World

Program information

I have created a class called "HelloWorld," which contains a simple main function within it. The class keyword specifies that we are defining a class. The name of a public class is written exactly the file name (case sensitive). All java programs begin execution with a method called main (). main execution method has the following signature: void main (String args []) public static declare this method as public transport which is accessible from outside the class to the JVM when trying to find the program to start. her. And 'necessary that the method is declared with a void return type (ie, no arguments are returned by the method). The main method contains an array of string arguments that can contain the command line arguments. The braces {and} mark the beginning and the end of the class. The program contains "System.out.println (" Hello "); 'a line that tells the computer to print a line of text to say,' Hello World 'The semicolon.'; 'End the line of code.' s double slashes '/ comments /' are used which can be used to describe what he is doing a source code. All right of the bars in the same line is not filled in, as they are only comments in a program.

Java Main method statements

class MainExample1 {public static void main(String[] args) {}}
class MainExample2 {public static void main(String []args) {}}
class MainExample3 {public static void main(String args[]) {}}

They are all 3 main valid method shown above takes a single argument array of strings.

Compile and run an application

To compile and run the program you need the JDK distributed by Sun Microsystems. The JDK contains documentation, examples, installation instructions, class libraries and packages, and instruments. Download editor like Textpad / EditPlus to write the code. You need to keep the source code, with an extension of Java .. The file name must be the name of the public class in the file.

Steps to follow to save, compile and run a Java application

Step 1:Save the program With .java Extension.
Step 2:Compile the file from DOS prompt by typing javac <filename>.
Step 3:Successful Compilation, results in creation of .class containing byte code
Step 4:Execute the file by typing java <filename without extension>


Java Development Kit

Java Developer Kit is distributed by Sun Microsystems. The JDK contains documentation, examples, installation instructions, class libraries and packages and tools

javadoc

The javadoc tool provided by Sun is used to produce the documentation of an application or a program,


Jar files

A JAR file is used to group related class files into a single file for more compact storage, distribution and transmission.


PATH and CLASSPATH

The following are general programming errors, which I think every beginning java programmer find. Here's a solution on how to solve problems when running on a Windows machine.

1. "Javac 'is not recognized as an internal or external command, program or batch file

When you get this error, you must conclude that the operating system can not find the compiler (javac). To resolve this error, you must set the PATH variable.

How to set the PATH variable?

First, the PATH variable is set so that you can compile and run programs from any directory without having to type the full path of the command. To set the path to the JDK on your system (Windows XP), add the full path to the JDK <version> \ bin to the PATH variable. Set the path follows on a Windows computer:

un. Click Start> Click on "My Computer" and click "Properties"
b. Variables Click Advanced> Environment.
c. Add the location of bin folder of JDK installation for PATH in User Variables and System Variables. A typical value for the path is:

C:\jdk<version>\bin (JDK <version is just the name of the directory where you installed the JDK)

If there is already some elements of the PATH variable should add a semicolon and then add the previous value (version is replaced with the version of the JDK). The new path takes effect in each new Command Prompt window you open after setting the PATH variable.


2. Exception in thread “main” java.lang.NoClassDefFoundError: HelloWorld

If you receive this error, Java can not find the file compiled bytecode, HelloWorld.class.If both class files and source code are in the same working directory, and if you try to run the program from the current working directory that the program should run smoothly as, try to find the Java class file. represents the current directory. If the class files are present in another directory than the java file we need to set the CLASSPATH pointing to the directory containing the compiled class files.CLASSPATH can be adjusted as follows on a Windows computer:

a. Click Start > Right Click “My Computer” and click on “Properties”
b. Click Advanced > Environment Variables.

Add the location of the folder class' that contains all Java classes in the user variables.

If there are already some items in your CLASSPATH must add a semicolon and then add the new value. The new classpath takes effect in each new Command Prompt window you open after setting the classpath.


Getting Started with Java JDK (Java Development Kit)

By: Admin on: 8:50 AM

Monday, August 5, 2013

Introduction to Computing with Java

Java is a simple but powerful programming and object-oriented and is in many ways similar to C + +. Java originated in Sun Microsystems, Inc. in 1991. E 'was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. has been developed to provide a platform-independent programming language. This site provides an introduction to programming in Java, with many examples of Java. It is a complete course for beginners Advanced Java Programming for Java.





Platform independent

Unlike many other programming languages ​​such as C and C + +, Java is compiled, it is compiled into platform specific machine, not the platform independent bytecode. This byte code is distributed via the Internet and interpreted by the virtual machine (JVM) in which the platform is running.

Java Virtual Machine

What is the Java Virtual Machine? What is your role?

Java was designed with a concept of "write once, run anywhere." Java Virtual Machine has a central role in this concept. The JVM is the environment in which Java programs are executed. This is a software that is distributed on top of real hardware and operating system. When you compile the source code (. Java), which translates bytecode and then placed in the file (. Class). The JVM executes this bytecode. So Java bytecode can be considered as the machine language of the JVM. A JVM can either interpret the bytecode one instruction at a time or the bytecode can be compiled further for the real microprocessor using what is called a just-in-time. The JVM should be implemented on a particular platform before compiling programs can run on that platform.

OOP  (Object Oriented Programming)

Since Java is an object-oriented programming has the following features:

  • Code reuse
  • The emphasis on data rather than procedure
  • Data is hidden and can not be accessed by external functions
  • Objects can communicate among them through the functions
  • New data and functions can be easily addedJava has powerful features. 


The following are some of them: -

  • Simple
  • Reusable
  • Portable (platform independent)
  • Distributed
  • Robust
  • Secure
  • High Performance
  • Dynamic
  • Screwed
  • Performed

Object-oriented programming is a method of execution in which the programs are organized in cooperative collection of objects, each of which represents an instance of a class, and whose classes are all members of a hierarchy of classes connected by inheritance relationships.

Concepts of object-oriented programming

Four principles of object-oriented programming are

  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism


Abstraction

Abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide the conceptual boundaries well defined, regarding the point of view of the viewer.

Encapsulation

Encapsulation is the process of partitioning the elements of an abstraction that constitute its structure and behavior, encapsulation serves to separate the contractual interface of an abstraction and its implementation.

Encapsulation

* Hides the implementation details of a class.
* Forces the user to use a data access interface
* It makes the code easier to maintain.

Inheritance

Inheritance is the process by which an object acquires the properties of another object.

Polymorphism

Polymorphism is the existence of classes or methods in different ways or only name that denotes different
implementations.

Java is distributed

With a wide range of routine to handle the TCP / IP protocol such as HTTP and FTP java can open and access objects across the network via URLs.


Java is multithreaded

One of the strengths of the Java language is that it allows multiple threads that execute the same program simultaneously on a single Java program can have many different threads running independently and continuously. Multiple Java applets can run in the browser at the same time sharing the CPU time.

Java is secure

Java was designed to allow safe execution of code across the network. To make sure Java many of the features of C and C + + have been removed. Java does not use. Java programs can not access arbitrary addresses in memory.

Garbage collection

Automatic garbage collection is another great feature of Java with the memory avoiding accidental damage. As in C + +, Java has a new operator to allocate memory on the heap for a new object. But it uses operator delete to free memory, as it does in C + + to free the memory when you no longer need the object. This is done automatically by the garbage collector.

Java Applications

Java has evolved from a simple language that provides interactive dynamic content for web pages with a programming language by companies registered mainly suitable for the development of important applications and critics. Today, it is used for many types of applications, including Web-based financial applications, gaming applications, embedded systems, distributed business applications, mobile applications, image processors, desktop applications, and more. This website describes the basic components of java that say some examples of Java, along with some Java tutorials.

Introduction of Java Programming

By: Admin on: 7:54 AM

 

Our Team Members

Copyright © 5G Download | Designed by Templateism.com | WPResearcher.com