Archive | Java

Use of Hibernate With Java Persistence Api

Use of Hibernate With Java Persistence Api

 
Before we start any discussion about Persistence technologies, we need to understand what exactly Persistence is in computer science. Persistence, in simple terms is the ability to retain data structures between various program executions. A perfect example of this would be a word processor saving undo history. In practice, this is achieved by storing the data in non- volatile storage such as a file system or a relational database or an object database.
 
The popularity of databases has increased manifold in the past few years. Java has become the preferred choice of developers for developing secure, flexible, and scalable database driven web applications. These web applications require objects to be associated with appropriate databases. Hibernate, along with other persistence technologies associate’s objects with the appropriate database in a simple, straight forward and natural way.
 
Hibernate is one such effort from the Java community to develop many object oriented solutions to data persistence. Any kind of Java persistence solution includes two main elements i.e. ORM (Object Relational Mapping) and OOM (Object Oriented Modeling).
 
Hibernate has become immensely popular amongst the developer community as it is a free, powerful, high performance open source object – relational mapping persistence Java package that makes it easier to work with relational databases for Java Applications.
 
Apart from Hibernate, other popular open source Java persistence technologies include JDBC, abates, JDO, Top Link and CMP Entity Beans. These technologies provide a standardized object-relational mapping mechanism.
 
Java persistence application programming Interface or JAVA Persistence API is the latest version of the Java Data Objects (JDO) technology which was the earlier persistent technology used by developers. JPA or the Java Persistence API is the latest Java Specification standard for java enterprise applications. The Java Persistence API is a java programming language framework that allows developers to manage relational data in Java standard edition and Enterprise Edition applications. Java Persistence API originated as part of the work of the JSR 220 expert group.
 
 
The java persistence API’s has been developed after drawing upon the best ideas from other prevalent persistence technologies like Top link, JDO, Hibernate etc. In simple words, Java Persistence API is a Plain Old Java Object API for object /relational mapping and supports a rich, SQL –like query language for both static and dynamic queries.Vendors involved in application development have found that the use of Hibernate technology with Java persistence API’s helps build flexible, database driven web applications that are highly scalable and involve complex business processes.
 
 
 
The Java Persistence API is the standard object/relational mapping and persistence management interface of the Java EE 5.0 platform and Java Web Services Development . As part of the EJB 3.0 specification effort, it is supported by all major vendors of the Java industry for improving Java Web Development in India and Globe.

More Java Articles

Go straight to Post

Posted in Java0 Comments

Encryption Using Rsa Algorithm in Java

Encryption Using Rsa Algorithm in Java

Encryption using RSA algorithm in java
 
Introduction
In this article I will provide you an approach of using RSA algorithm for long String. As you know that RSA algorithm is limited 117 bytes, long strings can not be encrypted or decrypted. However it is possible to break the bytes into several chunks and then to encrypt or decrypt the contents. This algorithm is used for asymmetric cryptography. For asymmetric cryptography, you can click this link.
 
Technicalities
In this article I provide below the complete example for encryption and decryption of long strings. If you use the method of Cipher class ie.doFinal( byte[] bytesString), it will throw exception that it can be encrypted for more than 117 bytes for RSA.  But in the real application, you may not be sure about the length of the String you want to encrypt or decrypt. In this case you have to break the bytes and then to encrypt it. Please refer to the
Following complete example.
 
Complete example
 
Class name : SecurityUtil.java
 
package com.dds.core.security;
 
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Security;
import java.security.spec.EncodedKeySpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
 
import javax.crypto.Cipher;
 
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
 
import com.sun.crypto.provider.SunJCE;
 
/**This is a utility class which provides
 * convenient method for security. This
 * class provides the way where you can
 * encrypt and decrypt the String having
 * more than 117 bytes for RSA algorithm
 * which is an asymmetric one.
 * @author Debadatta Mishra(PIKU)
 *
 */
public class SecurityUtil {
            /**
             * Object of type {@link KeyPair}
             */
            private KeyPair keyPair;
            /**
             * String variable which denotes the algorithm
             */
            private static final String ALGORITHM = “RSA”;
            /**
             * varibale for the keysize
             */
            private static final int KEYSIZE = 1024;
 
            /**
             * Default constructor
             */
            public SecurityUtil() {
                        super();
                        Security.addProvider(new SunJCE());
            }
 
            /**
             * This method is used to generate
             * the key pair.
             */
            public void invokeKeys() {
                        try {
                                    KeyPairGenerator keypairGenerator = KeyPairGenerator
                                    .getInstance(ALGORITHM);
                                    keypairGenerator.initialize(KEYSIZE);
                                    keyPair = keypairGenerator.generateKeyPair();
                        } catch (Exception e) {
                                    e.printStackTrace();
                        }
            }
 
            /**This method is used to obtain the String
             * representation of the PublicKey.
             * @param publicKey of type {@link PublicKey}
             * @return PublicKey as a String
             */
            public String getPublicKeyString(PublicKey publicKey) {
                        return new BASE64Encoder().encode(publicKey.getEncoded());
            }
 
            /**This method is used to obtain the String
             * representation of the PrivateKey.
             * @param privateKey of type {@link PrivateKey}
             * @return PrivateKey as a String
             */
            public String getPrivateKeyString(PrivateKey privateKey) {
                        return new BASE64Encoder().encode(privateKey.getEncoded());
            }
 
            /**This method is used to obtain the
             * {@link PrivateKey} object from the
             * String representation.
             * @param key of type String
             * @return {@link PrivateKey}
             * @throws Exception
             */
            public PrivateKey getPrivateKeyFromString(String key) throws Exception {
                        PrivateKey privateKey = null;
                        try {
                                    KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM);
                                    EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(
                                                            new BASE64Decoder().decodeBuffer(key));
                                    privateKey = keyFactory.generatePrivate(privateKeySpec);
                        } catch (Exception e) {
                                    e.printStackTrace();
                        }
                        return privateKey;
            }
 
            /**This method is used to obtain the {@link PublicKey}
             * from the String representation of the Public Key.
             * @param key of type String
             * @return {@link PublicKey}
             * @throws Exception
             */
            public PublicKey getPublicKeyFromString(String key) throws Exception {
                        PublicKey publicKey = null;
                        try {
                                    KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM);
                                    EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(
                                                            new BASE64Decoder().decodeBuffer(key));
                                    publicKey = keyFactory.generatePublic(publicKeySpec);
                        } catch (Exception e) {
                                    e.printStackTrace();
                        }
                        return publicKey;
            }
 
            /**This method is used to obtain the
             * encrypted contents from the original
             * contents by passing the {@link PublicKey}.
             * This method is useful when the byte is more
             * than 117.
             * @param text of type String
             * @param key of type {@link PublicKey}
             * @return encrypted value as a String
             * @throws Exception
             */
            public String getEncryptedValue(String text, PublicKey key)
            throws Exception {
                        String encryptedText;
                        try {
                                    byte[] textBytes = text.getBytes(“UTF8″);
                                    Cipher cipher = Cipher.getInstance(“RSA/ECB/PKCS1Padding”);
                                    cipher.init(Cipher.ENCRYPT_MODE, key);
 
                                    int textBytesChunkLen = 100;
                                    int encryptedChunkNum = (textBytes.length – 1) / textBytesChunkLen
                                    + 1;
 
                                    // RSA returns 128 bytes as output for 100 text bytes
                                    int encryptedBytesChunkLen = 128;
                                    int encryptedBytesLen = encryptedChunkNum * encryptedBytesChunkLen;
                                    System.out.println(“Encrypted bytes length——-”
                                                            + encryptedBytesChunkLen);
                                    // Define the Output array.
                                    byte[] encryptedBytes = new byte[encryptedBytesLen];
 
                                    int textBytesChunkIndex = 0;
                                    int encryptedBytesChunkIndex = 0;
 
                                    for (int i = 0; i
                                                if (i
                                                            encryptedBytesChunkIndex = encryptedBytesChunkIndex
                                                            + cipher.doFinal(textBytes, textBytesChunkIndex,
                                                                                    textBytesChunkLen, encryptedBytes,
                                                                                    encryptedBytesChunkIndex);
 
                                                            textBytesChunkIndex = textBytesChunkIndex
                                                            + textBytesChunkLen;
                                                } else {
                                                            cipher.doFinal(textBytes, textBytesChunkIndex,
                                                                                    textBytes.length – textBytesChunkIndex,
                                                                                    encryptedBytes, encryptedBytesChunkIndex);
                                                }
                                    }
                                    encryptedText = new BASE64Encoder().encode(encryptedBytes);
                        } catch (Exception e) {
                                    throw e;
                        }
                        return encryptedText;
            }
 
            /**This method is used to decrypt the contents.
             * This method is useful when the size of the
             * bytes is more than 117.
             * @param text of type String indicating the
             * encrypted contents.
             * @param key of type {@link PrivateKey}
             * @return decrypted value as a String
             */
            public String getDecryptedValue(String text, PrivateKey key) {
                        String result = null;
                        try {
                                    byte[] encryptedBytes = new BASE64Decoder().decodeBuffer(text);
                                    Cipher cipher = Cipher.getInstance(“RSA/ECB/PKCS1Padding”);
                                    cipher.init(Cipher.DECRYPT_MODE, key);
 
                                    int encryptedByteChunkLen = 128;
                                    int encryptedChunkNum = encryptedBytes.length
                                    / encryptedByteChunkLen;
                                    int decryptedByteLen = encryptedChunkNum * encryptedByteChunkLen;
                                    byte[] decryptedBytes = new byte[decryptedByteLen];
                                    int decryptedIndex = 0;
                                    int encryptedIndex = 0;
 
                                    for (int i = 0; i
                                                if (i
                                                            decryptedIndex = decryptedIndex
                                                            + cipher.doFinal(encryptedBytes, encryptedIndex,
                                                                                    encryptedByteChunkLen, decryptedBytes,
                                                                                    decryptedIndex);
                                                            encryptedIndex = encryptedIndex + encryptedByteChunkLen;
                                                } else {
                                                            decryptedIndex = decryptedIndex
                                                            + cipher.doFinal(encryptedBytes, encryptedIndex,
                                                                                    encryptedBytes.length – encryptedIndex,
                                                                                    decryptedBytes, decryptedIndex);
                                                }
                                    }
                                    result = new String(decryptedBytes).trim();
                        } catch (Exception e) {
                                    e.printStackTrace();
                        }
                        return result;
            }
 
            /**This method is used obtain the
             * {@link PublicKey}
             * @return {@link PublicKey}
             */
            public PublicKey getPublicKey() {
                        return keyPair.getPublic();
            }
 
            /**This method is used to obtain
             * the {@link PrivateKey}
             * @return {@link PrivateKey}
             */
            public PrivateKey getPrivateKey() {
                        return keyPair.getPrivate();
            }
}
 
The above class provides several useful methods for generation of Private key , Public Key and encryption of String and decryption of String.
 
Please refer to the following subordinate classes for the above class.
 
Class name : KeyGenerator.java
 
package com.dds.core.security;
 
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Properties;
 
/**This class is used to generate the
 * Private and Public key and stores
 * them in files.
 * @author Debadatta Mishra(PIKU)
 *
 */
public class KeyGenerator {
            /**This method is used to obtain the
             * path of the keys directory where
             * Private and Public key files are
             * stored.
             * @return path of the keys directory
             */
            private static String getKeyFilePath() {
                        String keyDirPath = null;
                        try {
                                    keyDirPath = System.getProperty(“user.dir”) + File.separator
                                    + “keys”;
                                    File keyDir = new File(keyDirPath);
                                    if (!keyDir.exists())
                                                keyDir.mkdirs();
                        } catch (Exception e) {
                                    e.printStackTrace();
                        }
                        return keyDirPath;
            }
 
            /**
             * This method is used to generate the
             * Private and Public keys.
             */
            public static void generateKeys() {
                        Properties publicProp = new Properties();
                        Properties privateProp = new Properties();
                        try {
                                    OutputStream pubOut = new FileOutputStream(getKeyFilePath()
                                                            + File.separator + “public.key”);
                                    OutputStream priOut = new FileOutputStream(getKeyFilePath()
                                                            + File.separator + “private.key”);
 
                                    SecurityUtil secureUtil = new SecurityUtil();
                                    secureUtil.invokeKeys();
 
                                    PublicKey publicKey = secureUtil.getPublicKey();
                                    PrivateKey privateKey = secureUtil.getPrivateKey();
 
                                    String publicString = secureUtil.getPublicKeyString(publicKey);
                                    String privateString = secureUtil.getPrivateKeyString(privateKey);
 
                                    publicProp.put(“key”, publicString);
                                    publicProp.store(pubOut, “Public Key Info”);
 
                                    privateProp.put(“key”, privateString);
                                    privateProp.store(priOut, “Private Key Info”);
                        } catch (Exception e) {
                                    e.printStackTrace();
                        }
            }
}
 
The above class is used to generate the Public and Private keys. It generates and stores them in different files called Public.key and Private.key. Please refer the test harness class for the above class.
 
Class name: TestKeyGenerator
 
import com.dds.core.security.KeyGenerator;
 
/**This is a testharness class
 * for the KeyGenerator class.
 * @author Debadatta Mishra(PIKU)
 *
 */
public class TestKeyGenerator {
      public static void main(String[] args) {
            KeyGenerator.generateKeys();
      }
 
}
If you run the above class, you will find a directory called keys in your root path of your application folder. In this folder you will find two files one is for Private Key information and another is for Public Key.
There is another class which is used to obtain the Private key and Public key information stored in the files.
 
Class name: KeyReader.java
 
package com.dds.core.security;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.PublicKey;
import java.util.Properties;
 
/**This class is used to read the
 * keys from the file.
 * @author Debadatta Mishra(PIKU)
 *
 */
public class KeyReader {
            /**This method is used to obtain the
             * string value of the Public Key
             * from the file.
             * @return String of {@link PublicKey}
             */
            public static String getPublicKeyString() {
                        String publicString = null;
                        try {
                                    Properties prop = new Properties();
                                    String publicKeyPath = System.getProperty(“user.dir”)
                                    + File.separator + “keys” + File.separator + “public.key”;
                                    InputStream in = new FileInputStream(publicKeyPath);
                                    prop.load(in);
                                    publicString = prop.getProperty(“key”);
                        } catch (Exception e) {
                                    e.printStackTrace();
                        }
                        return publicString;
            }
 
            /**This method is used to obtain the
             * String of Private Key from the file.
             * @return String of private key
             */
            public static String getPrivateKeyString() {
                        String publicString = null;
                        try {
                                    Properties prop = new Properties();
                                    String publicKeyPath = System.getProperty(“user.dir”)
                                    + File.separator + “keys” + File.separator + “private.key”;
                                    InputStream in = new FileInputStream(publicKeyPath);
                                    prop.load(in);
                                    publicString = prop.getProperty(“key”);
                        } catch (Exception e) {
                                    e.printStackTrace();
                        }
                        return publicString;
            }
}
 
This is a utility class to read the Public and Private keys from the files.
 
Now refer to the test harness class which makes encryption and decryption of String.
 
import java.security.PrivateKey;
import java.security.PublicKey;
 
import com.dds.core.security.KeyReader;
import com.dds.core.security.SecurityUtil;
 
/**
 * This is a test harness class for encryption and decryption.
 *
 * @author Debadatta Mishra(PIKU)
 *
 */
public class TestEncryption {
 
            public static void main(String[] args) {
                        String privateKeyString = KeyReader.getPrivateKeyString();
                        SecurityUtil securityUtil = new SecurityUtil();
                        String publicKeyString = KeyReader.getPublicKeyString();
                        try {
                                    PublicKey publicKey = securityUtil
                                    .getPublicKeyFromString(publicKeyString);
                                    PrivateKey privateKey = securityUtil
                                    .getPrivateKeyFromString(privateKeyString);
                                    String originalValue = “provide some very long string”;
 
                                    String encryptedValue = securityUtil.getEncryptedValue(
                                                            originalValue, publicKey);
                                    System.out.println(“EncryptedValue—–” + encryptedValue);
                                    String decryptedValue = securityUtil.getDecryptedValue(
                                                            encryptedValue, privateKey);
                                    System.out.println(“Original Value——” + decryptedValue);
 
                        } catch (Exception e) {
                                    e.printStackTrace();
                        }
            }
 
}
 
This test harness class is used to encrypt and decrypt the long string contents. You can also use the same method for file encryption and decryption. First you have to read the contents of a file as String and then you can apply method to encrypt it.
 
Conclusion
I hope that you will enjoy my article for this asymmetric cryptography for RSA. For asymmetric cryptography please refer to the link http://www.articlesbase.com/information-technology-articles/asymmetric-cryptography-in-java-438155.html. If you find any problems or errors, please feel free to send me a mail in the address debadattamishra@aol.com . This article is only meant for those who are new to java development. This article does not bear any commercial significance. Please provide me the feedback about this article

Go straight to Post

Posted in Java0 Comments

Use of Hibernate With Java Persistence Api

Use of Hibernate With Java Persistence Api

Before we start any discussion about Persistence technologies, we need to understand what exactly Persistence is in computer science. Persistence, in simple terms is the ability to retain data structures between various program executions. A perfect example of this would be a word processor saving undo history. In practice, this is achieved by storing the data in non- volatile storage such as a file system or a relational database or an object database.
The popularity of databases has increased manifold in the past few years. Java has become the preferred choice of developers for developing secure, flexible, and scalable database driven web applications. These web applications require objects to be associated with appropriate databases. Hibernate, along with other persistence technologies associate’s objects with the appropriate database in a simple, straight forward and natural way.
Hibernate is one such effort from the Java community to develop many object oriented solutions to data persistence. Any kind of Java persistence solution includes two main elements i.e. ORM (Object Relational Mapping) and OOM (Object Oriented Modeling).
Hibernate has become immensely popular amongst the developer community as it is a free, powerful, high performance open source object – relational mapping persistence Java package that makes it easier to work with relational databases for Java Applications.
Apart from Hibernate, other popular open source Java persistence technologies include JDBC, abates, JDO, Top Link and CMP Entity Beans. These technologies provide a standardized object-relational mapping mechanism.
Java persistence application programming Interface or JAVA Persistence API is the latest version of the Java Data Objects (JDO) technology which was the earlier persistent technology used by developers. JPA or the Java Persistence API is the latest Java Specification standard for java enterprise applications. The Java Persistence API is a java programming language framework that allows developers to manage relational data in Java standard edition and Enterprise Edition applications. Java Persistence API originated as part of the work of the JSR 220 expert group.
The java persistence API’s has been developed after drawing upon the best ideas from other prevalent persistence technologies like Top link, JDO, Hibernate etc. In simple words, Java Persistence API is a Plain Old Java Object API for object /relational mapping and supports a rich, SQL –like query language for both static and dynamic queries.
Vendors involved in application development have found that the use of Hibernate technology with Java persistence API’s helps build flexible, database driven web applications that are highly scalable and involve complex business processes.
The Java Persistence API is the standard object/relational mapping and persistence management interface of the Java EE 5.0 platform and Java Web Services Development . As part of the EJB 3.0 specification effort, it is supported by all major vendors of the Java industry for improving Java Web Development in India and Globe.

Go straight to Post

Posted in Java0 Comments

Hot Or Not? Developing Applications With Java Programming

Hot Or Not? Developing Applications With Java Programming

Java is a general purpose programming language similar to C++ and was developed by Sun Microsystems to take advantage of the flourishing World Wide Web. Java programming language is well designed to develop effective web based applications and offers many advantages over other languages like C++. Technically, Java source code files (.java files) are compiled into bytecode (.class files). This complied java code is then executed by a Java interpreter. Since Java interpreters and Runtime environments called Java Virtual Machines exist for most operating systems (Windows OS, UNIX and Macintosh), you can run java based applications on almost every computer!
Portability
As explained Java is platform independent language which means you can write your application on one computer and can run that application on all computers. Java support is built into all major OS and popular web browsers, making it available on virtually every Internet-connected computer worldwide. Even electronic devices like mobile phones, set-top boxes and PDAs nowadays come with inbuilt Java applications.
Efficient Programming and Timeliness
Java is designed to remove common programming errors and comes with excellent set of APIs making it easier for programmers to write bug free code than in other languages. This in turn reduces development time and cost of any application.
Dynamic Characteristic of Programs
Java is object oriented language and the source code is organized in small units called classes. Programs written with Java code automatically call and load these classes whenever it is required to run the application. This means applications written in Java can dynamically expand their functionality by loading these classes anytime from the Java interpreter.
Security
Fortunately, Java programming and platform community is prompt enough in fixing security related bugs. Any new security bug on Java platform immediately catches eye of media because of the promises given by Java community for security!
Like any other programming language, Java is not spared of snags and hitches. Java is an interpreted language and hence programs written in Java language runs comparatively slow. But with availability of faster processors at competitive prices, this barrier should be only a temporary one.
In India, there are many Java web development companies having experienced team of Java programmers to develop quality Java applications with best feasible solutions. They are capable of developing highly interactive web solutions for your business with effective project management support. If you want expert programmers to create competitive Java web applications at affordable rates then India is the best destination. You just need to find right offshore development partner that best suit your business needs and budget. Outsourcing your Java web development projects can save you significant amount of time and money.

Related Java Articles

Go straight to Post

Posted in Java0 Comments

Improve your programming knowledge through Java Training courses

Improve your programming knowledge through Java Training courses

Java Training
Importance of java
Java is an object-oriented programming language developed by Sun Microsoft.It is one of the development programming language. Java was chosen as the programming language for network computers. It can be trianed by good Java Training center.Java has distributed, secure, architecture, robust, multi threaded and dynamic language. The program can be written once, and run anywhere”. One of the most significant advantages of Java is that, it has the ability to move easily from one computer to another. It also has the ability to run the same program on many different operating systems.
Java Training applications are designed to be compiled and then interpreted at runtime, unlike the conventional programming languages, which can either compile source code to native code or interpret the source code. The language itself has borrowed the syntax from C and C++. Java considers security as a part of its design. The Java language, its compiler, interpreter, and runtime environment are all developed with security. Writing network programs in Java is similar to sending and receiving data to and from a file.
The Java Training programming language was developed and re-designed for use on the Internet. In the internet domain, Java’s popularity has increased tremendously, especially on the server side of the Internet. Nowadays, there are a large number of Java experts who strive for the enhancement and improvement of Java development. For beginners who are interested in learning Java, the numerous Java tutorials or Java Training available online are good to start with. Java tutorials or Java Training and Java tips are the best resources for learning and improvising in Java.
Java Training Development experts are trying to enhance their programming skills for writing secure Java applications. In order to write a secure code in Java you need to be aware of various things such as data handling techniques, user authentication rules, access controls etc. JavaScript is a scripting language which shares a similar name and has the same syntax, but is in no way related to the core Java language..
Java Training
Improve your programming knowledge through Java Training courses
Java Training
Java is an object-oriented programming language developed by Sun Microsoft.It is one of the development programming language. Java was chosen as the programming language for network computers. It can be trianed by good Java Training center.Java has distributed, secure, architecture, robust, multi threaded and dynamic language.The Java Training programming language was developed and re-designed for use on the Internet. In the internet domain, Java’s popularity has increased tremendously, especially on the server side of the Internet. Nowadays, there are a large number of Java experts who strive for the enhancement and improvement of Java development. For beginners who are interested in learning Java, the numerous
Fresherlab.com is a young organization, based at India’s IT hub, Bangalore. It’s a dynamic and competitive world with full of ups and downs in IT sector and therefore; the fresh engineers require just more than theoretical knowledge to get themselves ready for the industry. Academic institutions across the world provide the basic and conceptual fundamentals covering multiple areas in computer science. With increasing number of graduating engineers, but with constant number of companies, it becomes difficult for fresh engineers to compete with their unpolished skills because they need more effective and specialized quality training.

Go straight to Post

Posted in Java0 Comments

Java 2 Platform Enterprise Edition (j2ee) Three-tier Model

Java 2 Platform Enterprise Edition (j2ee) Three-tier Model

Enterprise edition of J2EE is used for developing modular enterprise request. It can be easily used on J2EE are distributed over 3 different locations, namely, J2EE server & database server, client machine, and at legacy system. The main advantages of using J2EE platform are:* High Performance* Lightweight Constant objects* High amount of flexibility in operation platform and configuration* Extensibility and maintainability* Interoperability* Focus on implementing business logic* It should be easy to add and maintain new functionality.Application logic used in Java 2 Platform Enterprise Edition us divided into different components depending on the function. They are differently installed on various machines totally depending on application it belongs to. For instance in Client machine, J2 EE server is divided into 2 main categories: Web Based Clients & application clients. Web based clients executes on a standard web browser. They do not typically execute intricate business rules, and database query. Usually heavy weights are offloaded to Enterprise java beans that help in controlling security, reliability and speed of J2EE server side technology. Whereas application clients run on Java Virtual machines that help in handling the richer user interface conveniently. Further they have the facility to access EJB on business tier as well. Similarly for other tier locations, there are assorted components.If you like to take the advantages of J2EE Three-Tier Model then contact a software development company now. They will give you the necessary information (including both advantages and disadvantages of this technology).<a rel=”nofollow” onclick=”javascript:pageTracker._trackPageview(‘/outgoing/article_exit_link’);” href=””http://www.icreonglobal.com/java-development.shtml””> Java Web Services India</a><a rel=”nofollow” onclick=”javascript:pageTracker._trackPageview(‘/outgoing/article_exit_link’);” href=””http://www.icreonglobal.com/java-development.shtml””> 2 Platform Enterprise Edition</a>

Go straight to Post

Posted in Java0 Comments

All about “JAVA”

All about “JAVA”

Java is basically a programming language,which was originally developed by James Gosling (best known as the father of the Java programming language) at Sun microsystems which is now a subsidiary of Oracle Corporation. It was first released by Sun in 1995. In short, it is the underlying technology that powers state-of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices.
Why do people need JAVA?
There are lots of applications and websites that won’t work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!
Characteristics of JAVA
The programs you create are portable in a network
The code is robust, here meaning that, unlike programs written in C++ and perhaps some other languages, the Java objects can contain no references to data external to themselves or other known objects.
Java is object-oriented, which means that, among other characteristics, an object can take advantage of being part of a class of objects and inherit code that is common to the class.
In addition to being executed at the client rather than the server, a Java applet has other characteristics designed to make it run fast.
Relative to C++, Java is easier to learn. (However, it is not a language you’ll pick up in an evening!)
Difference between JAVA and JAVASCRIPT
JavaScript should not be confused with Java. JavaScript, which originated at Netscape, is interpreted at a higher level and is easier to learn than Java, but lacks some of the portability of Java and the speed of bytecode. Because Java applets will run on almost any operating system without requiring recompilation and because Java has no operating system-unique extensions or variations, Java is generally regarded as the most strategic language in which to develop applications for the Web. (However, JavaScript can be useful for very small applications that run on the Web client or server.)
Editions
Sun has defined and supports four editions of Java targeting different application environments and segmented many of its APIs so that they belong to one of the platforms. The platforms are:
Java Card for smartcards.
Java Platform, Micro Edition (Java ME) — targeting environments with limited resources.
Java Platform, Standard Edition (Java SE) — targeting workstation environments.
Java Platform, Enterprise Edition (Java EE) — targeting large distributed enterprise or Internet environments.
Download
Java is free to download. You can get the latest version at http://java.com.
If you are building an embedded or consumer device and would like to include Java, please contact Oracle for more information on including Java in your device.
Why must you stay updated?
The latest Java version contains important enhancements to improve performance, stability and security of the Java applications that run on your machine. Installing this free update will ensure that your Java applications continue to run safely and efficiently.
Overall JAVA is a must for internet users to ensure a rich and wonderful experience on the web !

 

Go straight to Post

Posted in Java0 Comments

The Java Virtual Machine

The Java Virtual Machine

The Java Virtual MachineThe Java virtual machine is called “virtual” because it is an abstract computer defined by a specification. To run a Java program,you need a concrete implementation of the abstract specification. This chapter describes primarily the abstract specification of the Java virtual machine.To illustrate the abstract definition of certain features, however, this chapter also discusses various ways in which those features could be implemented.What ‘s the Java Virtual Machine?
To understand the Java virtual machine you must first be aware that you may be talking about any of three different things when you say “Java virtual machine.” You may be speaking of the abstract specification, a concrete implementation, or a runtime instance. The abstract specification is a concept, described in detail in the book: The Java Virtual Machine Specification, by Tim Lindholm and Frank Yellin.Concrete implementations, which exist on many platforms and come from many vendors, are either all software or a combination of hardware and software.A runtime instance hosts a single running Java application.Each Java application runs inside a runtime instance of some concrete implementation of the abstract specification of the Java virtual machine. In this book, the term “Java virtual machine” is used in all three of these senses. Where the intended sense is not clear from the context,one of the terms “specification,” “implementation,” or “instance” is added to the term “Java virtual machine”. The lifetime of a Java Virtual MachineA runtime instance of the Java virtual machine has a clear mission in life: to run one Java application. When a Java application starts, a runtime instance is born. When the application completes, the instance dies. If you start three Java applications at the same time, on the same computer, using the same concrete implementation,you’ll get three Java virtual machine instances. Each Java application runs inside its own Java virtual machine.A Java virtual machine instance starts running its solitary application by invoking the method of some initial class.The method must be public, static, return , and accept one parameter. Any class with such a method can be used as the starting point for a Java application.For example, consider an application that prints out its command line arguments:// On CD-ROM in file jvm/ex1/Echo.javaclass Echo { public static void main(String[] args) { int len = args.length; for (int i = 0; i { System.out.print(args[i] + ” “); } System.out.println(); }}You must in some implementation-dependent way give a Java virtual machine the name of the initial class that has the method thatwill start the entire application. One real world example of a Java virtual machine implementation is the program from Sun’s Java 2 SDK.If you wanted to run the application using Sun’s on Window98, for example, you would type in a command such as:java Echo Greetings, Planet.The first word in the command, indicates that the Java virtual machine from Sun’s Java 2 SDK should be run by the operating system.The second word, is the name of the initial class.must have a public static method named that returns and takes a array as its only parameter. The subsequent words, are the command line arguments for the application. These are passed to the method in the array in the order in which they appear on the command line. So, for the previous example, the contents of the array passed to main,The method of an application’s initial class serves as the starting point for that application’s initial thread.The initial thread can in turn fire off other threads.Inside the Java virtual machine, threads come in two flavors: daemon and non- daemon.A daemon thread is ordinarily a thread used by the virtual machine itself, such as a thread that performs garbage collection. The application, however, can mark any threads it creates as daemon threads. The initial thread of an application–the one that begins at –is a non- daemon thread.A Java application continues to execute (the virtual machine instance continues to live) as long as any non-daemon threads are still running.When all non-daemon threads of a Java application terminate, the virtual machine instance will exit. If permitted by the security manager, the application can also cause its own demise by invoking the method of class or .In the application previous, the method doesn’t invoke any other threads. After it prints out the command line arguments, returns. This terminates the application’s only non-daemon thread, which causes the virtual machine instance to exit.The Architecture of the Java Virtual MachineIn 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.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 thedesigners 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.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 wayin 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 discardsthe 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.

Go straight to Post

Posted in Java0 Comments

Aghreni Technologies Educational Services – Trainings on Open Source Technologies ( Perl, Php, Java, Ruby, Linux, Mysql)

Aghreni Technologies Educational Services – Trainings on Open Source Technologies ( Perl, Php, Java, Ruby, Linux, Mysql)

 Aghreni offers skill enhancement courses in · PErL, PHP, Ruby & java/J2ee· Unix/linux· Mysql· Web development· User interface design·  Veritas· Usability engineering· Project management· Leadership· Software development techniques· Software testing techniques

Go straight to Post

Posted in Java0 Comments

Accessing Ms Access Using Java

Accessing Ms Access Using Java

Step by step guide:

1.Create a database in ms access and add a table

2.Add columns to the table.

3.Go to control panel->Administrative Tools

->JDBC-> System DSN

4.In System DSN tab click on add ,choose

Microsoft access driver ,then you will get a

dialog box opened ODBC Microsoft access setup

mention the data source name in it and in

databases click on select button and choose

your .mdb file that is created in step1.

5.Register the driver using

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

6.Connect to the database

Connection con = DriverManager.getConnection

(URL,userid,password);

url=” Jdbc:Odbc:”

userid and password are empty in case of MS access.if it oracle default userid is “scott” password is “tiger”.

Ex: Connection con = DriverManager.getConnection

( “Jdbc:Odbc:msac”, “”,”");Source Code

import java.sql.*;

import java.io.*;

class JdbcDemo1

{

Connection con;

Statement stmt;

ResultSet rs;

JdbcDemo1(){

try{

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

con = DriverManager.getConnection( “Jdbc:Odbc:msac”, “”,”");

stmt = con.createStatement();

rs = stmt.executeQuery(“SELECT * FROM Table1″);

while (rs.next()) {

String x = rs.getString(“name”);

int s = rs.getInt(“age”);

System.out.println(“x:”+x+”s”+s);

}

}catch(SQLException e){

System.out.println(“Hello World!”+e);

}catch(ClassNotFoundException e){

System.out.println(“purni”+e);

}

}

}

class JdbcDemo

{

public static void main(String args[]){

new JdbcDemo1();

}

}

Related Java Articles

Go straight to Post

Posted in Java0 Comments