Skip to main content

Posts

When to use "Transient" keyword

/** Transient used to mark a variable not to be serialized So if you are serializing an object and you don't want to serialize a partecular variable value inside it, Then you just make it as transient and it will not be serialized Below example explains this concept */ package javabeat.samples; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; class NameStore implements Serializable{ private String firstName; private transient String middleName; private String lastName; public NameStore (String fName, String mName, String lName){ this .firstName = fName; this .middleName = mName; this .lastName = lName; } public String toStr...

GIF animation fixing zero delay issue

/*  * My GIF Viewer Version 1.0<br/>  * viewing animated Gif by either making it the default program <br/>  * to view it or by dragging the image into the program's frame.<br/>  * The animation can be controlled either you slow it down by pressing <  <br/>  * or speed it up by pressing >  *  */ package gif; import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; import mygifutil.MyGifUtil; import java.util.List; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; import j...
JPA troubleshooting this morning i got an error while inseritng an entity in the db Unknown entity bean class: class model.Doctor, please verify that this class has been marked with the @Entity annotation. the class is already having @Entity annotation , everything is set correctly only small thing i noticed ..the id is defined as int because during the process this bean is being populated from another bean and assigning int value to the id. Solution ..by changing both beans from int to long  this error disappeard :) another error happend with glass fish server java.lang.IllegalArgumentException: Object: is not a known entity type. this when deploying an app and glass fish did not wake up yet to realize that the version of the class is changed solution ..simply restart glassfish  :D

prevent SVN commit without a comment

Write the following  commands  inside the file Your  Subversion  repository /hooks/pre-commit.cmd SET REPOS=%1 SET TXN=%2  "C:\Program Files (x86)\VisualSVN Server\bin\svnlook.exe"  log %REPOS% -t %TXN% | findstr . > nul IF %ERRORLEVEL% EQU 1 GOTO ERR exit 0 :ERR echo. 1>&2 echo no commentsr: 1>&2 echo     please add comment before commit. 1>&2 echo Commit details: 1>&2 EXIT 1

java program to encode string to a valid url

public static String encodeURIComponent(String s)   {     String result = null;     try     {       result = URLEncoder.encode(s, "UTF-8")                          .replaceAll("\\+", "%20")                          .replaceAll("\\%21", "!")                          .replaceAll("\\%27", "'")                          .replaceAll("\\%28", "(")                ...