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

Tuesday, March 29, 2011

My experience learning JAVA

 My experience learning JAVA
I want ya story since the first experience of learning Java. First I started from the read-read tutorial java from SUN website. I go one-one tutorial page, complete one page and click next, and so on. Thank God that time the internet connection quite cepet. Then there's the reason I'll not have to read from the site, I wrote all the copy that is in part tutorial with web copier httrack. The program was immediately wrote nyedot all the links that exist from the first page of the tutorial. Wah deh happy to read and read at home. 'd Be in the office or cafe. One day, I fit into the cafe say nyari fad but a format JAVA tutorials. Chm. File. Chm is compiled from html form-2 that. Turns out there, yes I've donlot ajah tuh file. The amount of responsibility not abysmal tens of mega, mega 63 if not wrong. Although long, but more cepet of httrack, which was not yet finished. Well, that file readable tuh. From that day on the basics of JAVA I began to understand. Just be sure the problem is, I sometimes have problems with Java classes that are difficult to remember. Also difficult if not know of certain classes including a package (package) what. Therefore I also need download rich files. Chm about APIs in JAVA. If I search on google pake keyword 'JAVA API filetype: chm'. Found! There is a file. I immediately wrote donlot tuh file. Well now if confused the names of the class, I live search aja there. At that time I still use notepad.exe editor for programming. Wuaannjrrroooooottt! Learning JAVA wealth of torture really use the editor's time. Idly I open a page from SUN JDK download first place, there were Netbeans version 4 beta. He said it was a sophisticated editor, wrote the file size is about 100 mega. Mad. Yes already, coincidentally cafe where I was pretty spead. I download now. finished two hours later. Download Then I installed it at home. Incidentally I download who've integrated with JDK 1.5. Oh, no editor very slow. Weight if proceed. My computer is Athlon XP 2100, RAM 256, loading about 20 seconds or more. Not crazy? But alas, this is more cepet of JBuilder X that I have ever bought. Quite helpful also, especially by default netbeans can make a GUI program that cute-cute. Code hell can already delicious, rich in VB and Delphi, if the class name already typed, then typed ('.'), point variable name and method automatically appear. The point is pretty good. Sometimes there is also a problem with netbeans. In addition to slow, if create a console program (under DOS so rich), can kompail and run, but if the programs that we make have / need input from the keyboard, just netbeans pass wrote, so the error. I think what so can? Then, if he's my senior reading regular use Eclipse. Can download at eclipse.org. I try tuh donlot eclipse. Pretty big too, it was version 2.0 so if not wrong. Donlot out, I try at home. Editor is faster than netbeans. Loading Affairs does the same, but fitted kodingnya, it feels really different. The disadvantage, by default (without plugins) the editor has not provided the module to create GUI. So, if you want to use the GUI I use netbeans, if I use eclipse console. Actually there are plugins for eclipse that point we'll be coding the GUI with ease. This GUI includes a GUI applet and regular (desktop application). His name Jigloo. Donlot just try it, but I forgot the link, search on google aja with the keyword 'jigloo + eclipse + plugin'. Method of installation can be read on the site developer. You need to read the installation method because it is not just a coffee into the plugins directory. Well after that I almost always use the eclipse. If you need examples of Java programs, you can search the website JAVAALMANAC. This web site explains about the book Java Almanac can be purchased at Amazon.com. Buy not an option for me, but the web site there are many pieces of program based on its packets. Also given the title to fit the problem. Anyway mantep lah. Ordinary, I immediately wrote donlot use httrack. Tuh get quite a lot. Then I compail oh html so. HLP. With the format. Hlp, I could nyari-2 specific topics with ease. The problem is I forget the software that I use to kompail these html files. So much had deh stories. Hehehe .... Instead of patronizing, but bwegi-2 experience.
READ MORE - My experience learning JAVA

Monday, March 21, 2011

Needed an interpreter to run. class file compilation, interpreters can be contained in the Web-browser that has been to adopt Java to run Java applet, or can be in the form of interpreter java.exe to run java applications.

if the subroutine only represents a task, the object is a combination of data (in the form of instance variables - or "instance variables") and some assignment or called "behavior" of these data sets (in the form of an instance method - or "instance method"). Therefore, the object is a new structure that can handle the more complicated the complexity of a program

This section covers the manufacture and use of objects in the Java language. It will also discuss the core of object-oriented programming, namely: inheritance and poly morfisme (changes form).

JAVA is one oriented computer programming language objects, created by a team at Sun Microsystems, UNIX workstation company is quite famous. Java was created based on C + + language, with the goal of "platform independent" (can be run on various types of hardware without recompilation), with the slogan "Write Once Run Anywhere" (Wora). Compared with the language C + + then Java is essentially simpler, and using a pure object.

As an introduction to the Java application development team created the HotJava, an application written in Java. HotJava is the application of "Web-Browser " which is capable of running Java programs called "applets" on the webpage. The emergence of Java has been stimulating the emergence of the dynamics in the Web world, not static anymore, and can provide interactive services. Today all the Web-Browser has to support JAVA applications and even the emergence of Java has triggered the emergence of new things such as JavaScript, Visual J + +, Active-X etc., which try to emulate the power of Java in the Web world.

Although Java applications are generally designed for the Web, but in essence Java is the language "general purpose"that can be used to write programs in general as in the language C and C + +.

JAVA language does not appear suddenly, or because the discovery was accidental. JAVA origins began in 1991 when Sun Microsystems was doing research experiment in electronic products. James Gosling (the head of the research project) along with Patrick Naughton was assigned to design software that is independent, not dependent on the type of hardware to be used in various electronic equipment. James Gosling and then use the language C + + but it turns out he was facing many difficulties, and therefore created a new language based on C + + but with some improvements. This language was then called Oak, and is used to create intelligent software for electronic equipment made in Sun Microsystems. In 1994 when the Web became popular, the Oak language name later changed to JAVA (one reason, because it turns out the name Oak was first used for something else, then the name JAVA seems no one has used only used for names of hot coffee, and according to Gosling name is quite "cool", Gosling was inspired to use the name Java while drinking coffee). JAVA is then used to create a browser that is named WebRunner, after successfully HotJava browser is then called with the symbol hot cup of coffee.

Year 1995 is the year's most important for the Java language. Java and HotJava then published on the Web, Alpha version released in early 1995. JAVA was originally reserved only for SPARC Solaris, and is also implemented on Windows NT, and in the summer of 1995 a new in-implementation for Windows 95 and Linux. JAVA version of Beta 1 was announced in autumn 1995, then followed with a version of Beta 2 in December, at the same time MicroSoft and IBM expressed their support for Java technology.

On January 23, 1996, Java 1.0 was officially announced and made available on the Web for download, then one of the Netscape 2.0 browser and JAVA JAVASCRIPT famous adopted. JAVA development does not stop there, a variety of related technologies have now been introduced, such as J2EE (Java 2 Enterprise Edition), JavaBean, Java Server Page (JSP), and JME (Java Mobile Edition).

One of the capabilities of the Java language is to use the applet on a Web page for a form of interaction with website visitors, such as appears in one of the following Web page where the applet is used to study the history of Egypt.

According to the definition provided by Sun Microsystems, Java is a simple programming language, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, and dynamic.

Java language is simple: the design of the Java language dibust such a way that can be quickly identified and understood by the first programmer because it is similar in C / C + + and the second is simpler than the C / C + + in some ways, because things are difficult in C / C + + was removed in Java, for example the use of pointers.

Java language is simple: the design of the Java language is such that it can quickly be identified and understood by the first programmer because it is similar in C / C + + and the second is simpler than the C / C + + in some ways, because things are difficult in C / C + + was removed in Java, for example the use of pointers.

Java is an object-oriented language: the concept of objects applied to the manufacture of Java programs, even Java uses the concept of these objects are genuine, so it is not possible for a man to make Java programs without defining the class and use the object.

Java is a distributed language: Java language is designed in such a way that supports the creation of applications in computer networking. Java provides several classes-objects to support network applications compiled in the package java.net.

Java is a robust language: Java design is made, thereby reducing the possibility of the program becomes frozen (freeze) when run, the possibility of error is minimized, for example by applying the strong-typed so that the program can avoid the error because the wrong data type. Java memory model apply also to prevent the corrupted memory and overwrited, for example by removing the use of pointers.

Java is a secure language: Java automatically apply security to the application, thereby reducing the possibility of attacks from the network user.

Java is architecture neutral language: Java programs that have been compiled to run on various machines and does not depend on a single computer architecture course.

Java is a portable language: Java programs very easily moved from one machine to another without the re-compilation, because in fact when at-compile the Java program converted into a bytecode format that is received by all machines, then on each machine is available Java run-time-or Java-virtual-machine (JVM) that can run the bytecode.

Java is a language of high-performance: basically compiled C programs run much faster than Java, because the result of compiling C is the machine language of the computer used to compile, but not necessarily the result of this compilation can run on different computer architectures . Java programs are compiled into bytecode that can walk in different machines, but when run this bytecode to be interpreted by the JVM into the appropriate machine language, so much slower than C, but because Java can be used on computer networks that reality was not too fast because the barrier channel communication then the Java program still feels pretty fast.

Java is a multithreaded language: Java is designed to handle a variety of street applications simultaneously, such as playing a song, while doing the download, and users are doing scrolling on the window of his observed. This incident called multithreaded.

Java is a dynamic language: the Java language designed to adapt to its environment that can change quickly, Java can call the various class-object in times of need, despite having to go through the network, besides that it has a representation of the Java run-time so that the object being used by an application to be examined comes from a class through which run-time information.

Prior to the Java language was introduced as a programming language in general programming languages ​​such as Pascal, C and C + + using a compiler to translate the program into assembly language or machine language. BASIC language is known as a language interpreter where the program is compiled but not directly translated by the interpreter on the line when the program is typed into the computer memory.

Java language is essentially using the second technique, the compiler and interpreter. When a Java program that is being edited, will be recorded the name of the file must have the extension. java. The file is then in-source compilation with javac compiler into bytecode files, not the assembly and not the machine language. The results of this compilation of bytecodes are stored in files with extensions. class, this file can not be executed (execution) because no machine or assembly language.

Needed an interpreter to run. class file compilation, interpreters can be contained in the Web-browser that has been to adopt Java to run Java applet, or can be in the form of interpreter java.exe to run java applications.

Java interpreter commonly referred to as a JVM (Java Virtual Machine) provided by Sun Microsystems for each platform, with this technique, the Java program can Wora slogan, because the in-distribution program is the result of compilation. class that looks the same on every platform, then later after. This class will run, then only then is interpret by each existing JVM on every platform.
READ MORE - Needed an interpreter to run. class file compilation, interpreters can be contained in the Web-browser that has been to adopt Java to run Java applet, or can be in the form of interpreter java.exe to run java applications.

Wednesday, September 1, 2010

The Architecture of the Java Virtual Machine

Java Virtual Machine

Java Virtual Machine like its real counter part, executes the program and generate output. To execute any code, JVM utilizes different components.

JVM is divided into several components like the stack, the garbage-collected heap, the registers and the method area. Let us see diagram representation of JVM.

The Stack

Stack in Java virtual machine stores various method arguements as well as the local variables of any method. Stack also keep track of each an every method invocation. This is called Stack Frame. There are three registers thats help in stack manipulation. They are vars, frame, optop. This registers points to different parts of current Stack.

There are three sections in Java stack frame:
Local Variables

The local variables section contains all the local variables being used by the current method invocation. It is pointed to by the vars register.
Execution Environment

The execution environment section is used to maintain the operations of the stack itself. It is pointed to by the frame register.
Operand Stack

The operand stack is used as a work space by bytecode instructions. It is here that the parameters for bytecode instructions are placed, and results of bytecode instructions are found. The top of the operand stack is pointed to by the optop register.
Method Area

This is the area where bytecodes reside. The program counter points to some byte in the method area. It always keep tracks of the current instruction which is being executed (interpreted). After execution of an instruction, the JVM sets the PC to next instruction. Method area is shared among all the threads of a process. Hence if more then one threads are accessing any specific method or any instructions, synchorization is needed. Synchronization in JVM is acheived through Monitors.
Garbage-collected Heap

The Garbage-collected Heap is where the objects in Java programs are stored. Whenever we allocate an object using new operator, the heap comes into picture and memory is allocated from there. Unlike C++, Java does not have free operator to free any previously allocated memory. Java does this automatically using Garbage collection mechanism. Till Java 6.0, mark and sweep algorithm is used as a garbage collection logic. Remember that the local object reference resides on Stack but the actual object resides in Heap only. Also, arrays in Java are objects, hence they also resides in Garbage-collected Heap.

The Architecture of the Java Virtual Machine

In the Java virtual machine specification, the behavior of a virtual machine instance is described in terms of subsystems, memory areas, data types, and instructions. These components describe an abstract inner architecture for the abstract Java virtual machine. The purpose of these components is not so much to dictate an inner architecture for implementations. It is more to provide a way to strictly define the external behavior of implementations. The specification defines the required behavior of any Java virtual machine implementation in terms of these abstract components and their interactions.

Figure 5-1 shows a block diagram of the Java virtual machine that includes the major subsystems and memory areas described in the specification. As mentioned in previous chapters, each Java virtual machine has a class loader subsystem: a mechanism for loading types (classes and interfaces) given fully qualified names. Each Java virtual machine also has an execution engine: a mechanism responsible for executing the instructions contained in the methods of loaded classes.

When a Java virtual machine runs a program, it needs memory to store many things, including bytecodes and other information it extracts from loaded class files, objects the program instantiates, parameters to methods, return values, local variables, and intermediate results of computations. The Java virtual machine organizes the memory it needs to execute a program into several runtime data areas.

Although the same runtime data areas exist in some form in every Java virtual machine implementation, their specification is quite abstract. Many decisions about the structural details of the runtime data areas are left to the designers of individual implementations.

Different implementations of the virtual machine can have very different memory constraints. Some implementations may have a lot of memory in which to work, others may have very little. Some implementations may be able to take advantage of virtual memory, others may not. The abstract nature of the specification of the runtime data areas helps make it easier to implement the Java virtual machine on a wide variety of computers and devices.

Some runtime data areas are shared among all of an application's threads and others are unique to individual threads. Each instance of the Java virtual machine has one method area and one heap. These areas are shared by all threads running inside the virtual machine. When the virtual machine loads a class file, it parses information about a type from the binary data contained in the class file. It places this type information into the method area. As the program runs, the virtual machine places all objects the program instantiates onto the heap. See Figure 5-2 for a graphical depiction of these memory areas.

As each new thread comes into existence, it gets its own pc register (program counter) and Java stack. If the thread is executing a Java method (not a native method), the value of the pc register indicates the next instruction to execute. A thread's Java stack stores the state of Java (not native) method invocations for the thread. The state of a Java method invocation includes its local variables, the parameters with which it was invoked, its return value (if any), and intermediate calculations. The state of native method invocations is stored in an implementation-dependent way in native method stacks, as well as possibly in registers or other implementation-dependent memory areas.

The Java stack is composed of stack frames (or frames). A stack frame contains the state of one Java method invocation. When a thread invokes a method, the Java virtual machine pushes a new frame onto that thread's Java stack. When the method completes, the virtual machine pops and discards the frame for that method.

The Java virtual machine has no registers to hold intermediate data values. The instruction set uses the Java stack for storage of intermediate data values. This approach was taken by Java's designers to keep the Java virtual machine's instruction set compact and to facilitate implementation on architectures with few or irregular general purpose registers. In addition, the stack-based architecture of the Java virtual machine's instruction set facilitates the code optimization work done by just-in-time and dynamic compilers that operate at run-time in some virtual machine implementations.

See Figure 5-3 for a graphical depiction of the memory areas the Java virtual machine creates for each thread. These areas are private to the owning thread. No thread can access the pc register or Java stack of another thread.
READ MORE - The Architecture of the Java Virtual Machine
 
THANK YOU FOR VISITING