Posts

Showing posts from June, 2013

Java program to get the details about memory

Hi everyone, in this post, I am writing about how to get the details of maximum memory, free memory, total memory and used memory in java. maxMemory() - Specifies the maximum amount of memory java virtual machine will attempt to use. maxMemory is returned in bytes totalMemory() - Specifies the total amount of memory in java virtual machine. The totalMemory will vary according to the host environment. totalMemory is returned in bytes. freeMemory() - Specifies the amount of free memory in jvm. freeMemory is returned in bytes. The information about all these memory types are provided by Runtime class of java. The memory used by jvm can be obtained from different methods of the Runtime class. Following java program specifies a clear idea about getting details about  3 types of memories. package  com.techjourney; /**  * Created with IntelliJ IDEA.  * User: Sujith  * Date: 6/19/13  * Time: 11:17 PM  * To change this template use File | Settings | File Templates.  */ pub

instanceof operator in java

Hi everyone, in this blog post, I will be describing about instanceof operator in java. Instanceof operator is mainly used to specify whether an object is an instance of a class. It allows to determine the type of the object. It is a boolean operator which returns true if the object is an instance of the specified class.  Instanceof operator is a useful tool when there is a collection of objects and we are not sure why they are used. Here is a sample program which will give a better idea about the instanceof operator. package  com.example; import  java.util.ArrayList; import  java.util.HashMap; import  java.util.LinkedHashSet; import  java.util.List; import  java.util.Map; import  java.util.Set; public   class  InstanceOfExample {      public   static   void  main(String[] args) {         List myList =  new  ArrayList<>();         Map myMap =  new  HashMap<>();         Set mySet =  new  LinkedHashSet<>();                  System.out.println( &qu

Sample jdbc program using oracle database

Image
Hi everyone, in this post, I will be writing about a sample jdbc program using oracle database. I hope everyone have gone through my earlier post, sample program using HSQL DB . Connection of oracle database is almost similar to connection with hsql db, except the name of connection url and class for connection. Connection URL = "jdbc:oracle:thin:@localhost:1521" Class.forName("oracle.jdbc.driver.OracleDriver") Here, I am writing a jdbc program to fetch the values from a table. The sample jdbc program for oracle database is as follows : import  java.sql.Connection; import  java.sql.DriverManager; import  java.sql.ResultSet; import  java.sql.SQLException; import  java.sql.Statement; public   class  OracleDatabase {      public   static   void  main(String[] args) {                  System.out.println( " Oracle Database " );         System.out.println();          try         {             String connectionURL = "jdbc:oracle:th

Deploying application of Google Web Toolkit on Tomcat Server

Image
Hi Everyone, in this blog post, I will describe about how to display the application for Google Web Toolkit in Apache Tomcat. Apache Tomcat is an open source web server and servlet container developed by the apache software foundation. Please check the reference for knowing more about tomcat server. This blog is based on my previous blog post - Sample Application in GWT.  Please go through my previous blog post to get a better idea. In this post, I will be deploying the application, which I wrote in the previous blog in tomcat. Deployment is the term used for installing an application in your server. In tomcat, the web application itself is setup in 2 different ways, which are : Statically - The web application is setup in tomcat before it is started. Dynamically - By directly manipulating already deployed applications or remotely by using tomcat web application manager. Following are the steps to be followed to deploy the application in tomcat. For deploying the applica

Sample program for GWT

Image
Hi everyone, in this blog post, I will be writing a sample program on GWT. Please go through my previous post, Introduction to GWT , which will give you a basic idea about GWT. Here, I am creating a sample gwt application which displays an alert button. The name of the project is SampleGWT. To create a project, click on the google icon in eclipse and choose "New Web Application Project". The main folders in a gwt application are as follows :- 1) src - src include the source folder, where the source code is written. In GWT src includes, a) Client folder - Contains java classes for User Interface. The entry point of the application will be usually in client folder. b) Server folder - Contains java classes for server side processing. Usually server folder includes servlets. c) Shared folder - Contains java classes for transferring data from client to server. d) Module descriptor file - This file will be named as our project_name.gwt.xml. This file is required f