Friday, January 21, 2011

Memory Leaks in Java

One of the beauties of using Java programming language is that the programmers need not worry about the memory allocation and freeing of objects. We simply declare and initialize objects and JVM (Java Virtual Machine) will take care of freeing them when they are no longer in use by any application through a mechanism called 'garbage collection'. Before we start our topic, let us check how the memory is allocated for the objects.
Generally, the objects which are created using the 'new' keyword are allocated in 'memory heap' and the objects that are used for the method arguments and method variables are created into a 'stack'. When these objects are no more referred or when they are out of scope, they are eligible for garbage collection. The statement System.gc(); only suggest the JVM to perform a garbage collection and we can't force the JVM to do it, but the JVM may do it when the system is running short of memory.
Though JVM manages the memory, we can't be sure about the memory leaks. One can still have memory leak by poor programming (may be by keeping the references to null for too many objects in an application). If the Java program is written to run continuously in a server,even small memory leaking is risky. And a relatively small program also can reach the memory limit by using large number of temporary objects or objects that take large amount of memory. In such cases, Java holds memory for the unused objects and the application may run out of memory. JVM memory leaking is not dangerous as much as C++ memory leaking where the memory does not return to the operating system after the crash of the application. But in java programs, objects are created in the memory given to the JVM by the operating system. So when the JVM is closed, memory will return back to the OS.
If, there comes java.lang.OutOfMemoryError exception while executing a java application, your program may have memory leak. Finding the reason for memory leak can be difficult. By watching some of the common problems we can control the memory leaks. Some of the collection classes which is declared as static or which lives for the lifetime of an application such as hashmaps and vectors are common places where we can find memory leaks. Another common place is when we register an event listener toa class and forget to unregister it when it is not needed. We can use debugging tools like JProbe Suite, Optimizeit Enterprise Suite, Win32 Java Heap Inspector etc for fixing the memory leaks in java programming.
Julian is a professional content writer on java development and now working at Telious Technologies.

Thursday, January 13, 2011

Java Programming For Games

Do you often play games on your mobile phones? Maybe you often ask, what programs and applications used to create these games? There are many types of programs that can be used to build a computer application, such as gaming, security system for a basic level, database systems, and much more. Some languages programming that can be used to create a fairly simple game such as "Java Language" program. This type of program as well as easy to apply, is also quite easy to be developed into some other applications, such as Java C+ and C++.
Use for gaming applications typically do not depend on the particular type of operating system, this is because the existing database on the program consists of several simple source code, so this kind of programming language can be used by them that still learning about this program, because some of this program based on source code applications. However, to further optimize the function of the Java program, it needs some additional knowledge to better understand and make modifications for this program, for example with the application "Turbo Pascal" which is a basic-level programming language.
If you want to try and learn to make a game with the application of "Java", there are some steps you should know, including:
• Type of game you want to develop? What is included in the game type "animation effect" or the game kind of "three dimensional". It is very important for you to start building these applications, because both types of these games require some source code that is different.
• What is the games platform you want to use, does require operating system support, such as "Windows", or just need a simple application, such as "Notepad". Both types of these applications will determine the type of game that will be produced later.
Both of these applications you must understand first before you begin to development of an application to learn for simple practices around the "Java Language", although it looks easy and simple, but if those two things are not understood properly, chances are you will have difficulty in applying these application.
Outsourcing Java programming - Texas based software development services.

Thursday, January 6, 2011

Java Application Programming - Components and Various Development Tools

Java is a very popular programming language which involves various syn-taxes from C++ and C language. But it has a simpler model then these two other complex programming languages. It has object model and low-level facilities for the users which makes it easier and simpler to use and understand.
Java Application Programming was developed by a person named James Gosling in 1995, at a present date subsidiary of Oracle Corporations, which was then called as sun Micro-systems. JVM or Java Virtual Machines are needed to run these java applications which are compiled to class file format. Irrespective of the computer architecture JVM is always required to run this type of files. Java Application Programming is specifically designed to have the least amount of implementation bottlenecks. It works on the principle of "write once, run anywhere" pattern.
It means once your write the coding of the program, you can use it on other destination too. You don't need to write it again and gain every time. Java is not only a programming language but also a software platform, which lets the application developers to use this simpler, class based and object-oriented programming language instead of the complicated high level languages like C and C++.
But the major disadvantage of using Java Application Programming is that, the programs written in Java are slower and need more memory space to get stored then the programs written in C language.
For that concern, the sun Micro-systems have been working upon java technologies under the specifications of the Java community process. And have achieved remarkable success in the context of introducing Just in time compilation model to run these applications in the year 1997-98. Some new language features have been added to the language like inner classes, optional assertions and String-buffer class etc.
Java has compilers in it, which conduct the basic functions whenever an application developer writes a code with syn-taxes and characters to run a particular Java Application Programming code.
For faster speed a company names Systronix has developed a micro-controller called jStik based on a line of java processors. A standard edition for Java Application Programming language has various components. It uses multi-tier architecture for database connectivity. It uses XMl files to store data and writing codes. JDOM is used for outputting XML data from Java code.
All the components of java work together to perform a given task, and such components are listed below:
1. Development tools and APIs as Java complier, Java debugger, Javadoc and JPDA
2. Deployment technologies could have sub-parts like Java web-start and Java plug-in
3. User interface tool kits are swing, AWT, sound, input methods, java 2D and accessibility.
4. Integration APIs are RMI, JDBC, JNDI, and CORBA.
5. Core APIs are like XML, logging, beans, Locale support, Preferences, Collections, JNI, Security, Lang, Util, New I/O and Networking
6. Java virtual machines are of three types as, Java hotspot client compiler, Java hotspot server complier ad Java hotspot VM runtime.
The various Java platforms are:
• Solaris
• Linux
• Windows
• And others.
Know more about the java application programming and the services regarding the same.

Sunday, January 2, 2011

Syntax Error dan Run Time Error

Kita kan sudah pernah membuat sebuah program java (minimal yang sederhana) bukan ? Kadang dalam proses kompilasi sebuah program maupun pada saat menjalankannya kita akan menemukan kesalahan / pesan error. Error ini dibagi menjadi 2 macam : 
  • Compile-Time Error atau yang disebut dengan Syntax Error. Ini biasanya terjadi karena : 
  1. kesalahan penulisan , misalnya lupa memberikan tanda titik koma pada akhir pernyataan, Java akan menunjukkan baris/kode yang terdapat kesalahan tersebut namun kadang petunjuk inipun bisa salah.
  2. Dalam kapitalisasi, ejaan, atau penggunaan karakter yang tidak benar.
Jika kita mendapati banyak pesan error, koreksi satu persatu mulai dari kesalahan pertama, kompile ulang, dan lihat hasilnya, dengan demikian kita akan mengurangi jumlah kesalahan / error yang sudah ada. Terkadang kesalahan selanjutnya itu disebabkan kesalahan yang pertama. Jadi menghemat bukan ? :)
  • Run time Errors, Sebuah program yang berhasil dikompile belum tentu berhasil di jalankan. Inilah yang dinamakan Run time error, kesalahan ini tidak akan ditampilkan sampai kita menjalankan program tersebut. Hal ini bisa saja terjadi misalnya dikarenakan struktur yang di buat programmer tidak jelas atau mungkin tidak logis.
Demikian Kawand sekalian semoga bermanfaat ya :)

Keep posting --> Blogging Campaign

Wednesday, December 29, 2010

Langkah - Langkah Membuat Program Java

Langkah langkah membuat program Java :
  • Menuliskan program dengan teks editor. Contoh tekx editor yang dapat digunakan antara lain Notepad, vi, emacs, dan sebagainya
  • Menyimpan hasil program dengan ekstensi .java. 
  • Kompilasi program tersebut dengan menggunakan Java Compiler. Hasil kompilasinya berupa berkas bytecode dengan ekstensi .class. berkas ini kemudian akan dikonversikan oleh Java Interpreter menjadi bahasa mesin sesuai dengan jenis dan platform yang digunakan.
Ok sekarang kita coba untuk menuliskan program sederhana dengan bahasa. Kita bisa menggunakan editor yang tersedia , misalnya Textpad, Notepad dan sebagainya. Pada Latihan ini Kita menggunakan Textpad saja yang lebih ringan dan mudah diimplementasikan.

public class Pertama
    public static void main(String args[])
    System.out.println("Program Pertamaku");

Untuk mengetahui bagaimana output program tersebut kita ikuti langkah - langkah berikut :
  • Pilih tools , Compile Java atau Tekan Ctrl + 1
  • Selanjutnya Akan muncul Command Result, Biasanya apabila tidak ada kesalahan maka akan ditampilkan halaman utama program dan pesan Tool completed successfully pada command result atau pada pojok kiri bawah program. 
  • Setelah berhasil di compile , Pilih Tools , Run Java Application atau tekan Ctrl+2 dan akan muncul output
Baris pertama adalah nama class yang kita buat. yaitu Pertama. Nah dalam java , penulisannya bersifat Case Sensitive artinya penulisan huruf besar dan kecil akan dianggap berbeda. Untuk penamaannya menggunakan ekstensi .java dan harus sama persis dengan class yang kita buat. Jadi kita ngesavenya harus "". 

Program java minimal akan menjalankan satu fungsi yaitu main , kata void di depannya berarti fungsi ini tidak akan mengeluarkan nilai baik (return value). Kurung kurawal buka berarti menandai awal perintah yang akan dieksekusi dan harus ditutup dengan kurung kurawal tutup. Jadi kurung kurawal yang dipakai selalu berjumlah genap. 
System.out.println digunakan untuk membuat keluaran. sedangkan kalimat yang berada di antara tanda petik itu merupakan konstanta string yang akan di tampilkan pada layar (output). 

Selamat mencoba semoga bermanfaat.

Let's keep Blogging (Blogging Campaign)