It is very often required to test the internet connection for performing some operations. If there is no internet connection established, then alternative logic will be executed. Java provides useful classes in java.net package for connecting to the internet. Here I written a very simple example to test if your system is connected to internet. …
Java
FileStore in Java 7
FileStore is new class introduced in Java 7.0. It is part of java.nio package. This class helps in geting the type of storage for the files stored whether it’s a device, partition or concreate file system. Also this class defines the list of methods which is useful for getting information about the file storage such …
Difference Between Throw and Throws in Exception Handling
When you are working with exception handling in Java, use of throw and throws may confuse you if you not familiar with the exception handling. Both are important keywords used frequently used in handling the exceptions. Throw is used for explicitly throwing an exception. Throw attribute in method signature, is a hint to the compiler …
Instance Initializer in Java
Instance initializer in Java is used for initializing the instance variables inside a class. It is a simple block without any modifiers used inside any class. If you declare a instance variable with value, then this value can be overridden in the instance initializer or in the constructor. The order of the execution as follows: …
JPA Vs Hibernate
I have come across this question from many of our readers and who ever working on the hibernate framework : What is the difference between Java Persistence API (JPA) and Hibernate ORM Framework. This post simply answer to those who are confusing with JPA and Hibernate difference. JPA and Hibernate Difference JPA is a specification for …
Difference Between Class.forName() and ClassLoader.loadClass()
Class.forName() and ClassLoader.loadClass(), both the classes dynamically loading the classes to the classpath. However, there are subtle difference on initializing the classes at the time of loading and from where it is loaded. This tutorials compares both the form of class loading with simple examples. Class.forName() By default the classes are initialized at the time …
Deprecated @Entity Annotation in Hibernate 4
In the earlier versions of Hibernate, we use @Entity for marking a class as persistence entity in the database. It has list of attributes to be used as the parameters. @Entity has been deprecated from the hibernate 4 and will be removed from the hibernate 5.0 release. There is a confusion in the consistency of …
How To Change Tomcat Default Port Configuration?
Tomcat uses by default on port number 8080 on your computer. It is very common that you would have conflict of port number if there is another service running on the same port. You can change the port number for your tomcat server by changing in the configuration file or through the eclipse editor. 1. …