Thursday, 28 August 2008
Java Class File Editor
Quite an interesting tool to work on Java class files.
"This is a tool to open Java class file binaries, view their internal structure, modify portions of it if required and save the class file back. It also generates readable reports similar to the javap utility. Easy to use Java Swing GUI. The user interface tries to display as much detail as possible and tries to present a structure as close as the actual Java class file structure. At the same time ease of use and class file consistency while doing modifications is also stressed. For example, when a method is deleted, the associated constant pool entry will also be deleted if it is no longer referenced. In built verifier checks changes before saving the file. This tool has been used by people learning Java class file internals. This tool has also been used to do quick modifications in class files when the source code is not available. "
Java Class File Editor - http://classeditor.sourceforge.net/
Labels:
class file,
class file editor,
editor,
file editor,
java,
major version,
minor version,
tool
Tuesday, 26 August 2008
Laucher for Java desktop application
Launching my Java desktop application in windows environment just by mouse clicks, this was my requirement. In my normal approach, where in which I have an application jar file and a couple of other supporting libraries, the command line invoking was quite annoying. This is because I may use a .bat file, and running this will open up a window, and I don't really want all these to happen.
So I have started searching and ended up with evaluating Launch4j (http://launch4j.sourceforge.net/), a pretty good tool for my needmake a launcher application. This tool can be used to wrap applications on Windows, Linux, Mac OS X and Solaris and available under BSD license.
In my case, I was quite lucky, because all the required jar files (application and libraries), JRE etc are available in same location in all machines. So I have to just make the launcher .exe and distribute ...
(1) Make all libraries available (Say under folder c:), and lauch the Launch4j
(2) Fill in the required details under `Basic` tab.
(3) Fill in the details under the `Classpath` tab
(4) If we need to run the application as a single instance, provide the details under `Single instance` tab
(5) Specify any JRE related configurations under `JRE` tab
(6) Click on the Build Wrapper button from the top,
This will create a configuration file (xml) and an exe file which is going to be the launcher.
Tray Icon in Java 6
I am much biased to web applications, the reason is that the new approaches that emrges every day facinated me a lot. But I am interested in destop based application (think client) also. When considering a Java application, taking the adavantage of OS System Tray/ Task Bar was not so easy until Java 6. But the latest release helped developers to a great extend. Here I have gicen a small Java program that can do the wonder of System Tray utilization, thanks Java 6.
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JOptionPane;
/**
* ApplicationExecuter
* @author Rajeev Nair
*/
public class ApplicationExecuter {
/**
* main method
* @param args - any command line arguments
*/
public static void main(String args[]){
if (!SystemTray.isSupported()){
System.out.println("System tray not supported on this platform");
System.exit(1);
} //end if
try {
doTrayStartUp();
} catch(Exception exp){
System.out.println("Exception occured while building the tray entry :(");
exp.printStackTrace();
} //end exception
} //end main
/**
* Creates a tray icon.
* @return TrayIcon
*/
private static TrayIcon createTrayIcon() {
// I have used an absolute path for image here .. :(
Image image = Toolkit.getDefaultToolkit().getImage("C:\\Apps\\Icons\\app.gif");
PopupMenu popup = createTrayMenu();
TrayIcon ti = new TrayIcon(image, "Example TrayIcon :)", popup);
ti.setImageAutoSize(true);
return ti;
} //end createTrayIcon
/**
* Creates a popup menu.
* @return PopupMenu
*/
private static PopupMenu createTrayMenu() {
// creating popup
PopupMenu menu = new PopupMenu();
// creating an entry element
MenuItem aboutItem = new MenuItem("About Example App!!!");
aboutItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, "Hello, :)",
"About Example App!!!", JOptionPane.INFORMATION_MESSAGE);
}
});
// addding an entry to popup menu
menu.add(aboutItem);
// adding a separator
menu.addSeparator();
// creating an entry element
MenuItem exitItem = new MenuItem("Exit");
exitItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
// addding an entry to popup menu
menu.add(exitItem);
return menu;
} //end createTrayMenu
/**
* Building the tray entry
* @throws Exception
*/
private static void doTrayStartUp() throws Exception{
SystemTray sysTray = SystemTray.getSystemTray();
TrayIcon trayIcon = createTrayIcon();
sysTray.add(trayIcon);
trayIcon.displayMessage("Example App", "Example App started", TrayIcon.MessageType.INFO);
// add mouse listners
trayIcon.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
if(e.getButton() == 1){
// if left button pressed
JOptionPane.showMessageDialog(null, "You have pressed the left button of the mouse.",
"Example App!!!", JOptionPane.INFORMATION_MESSAGE);
} //end if
}
public void mouseReleased(MouseEvent e) {}
});
} //end doTrayStartUp
}
Screen shots after running this program,
Monday, 21 July 2008
How to run tomact with custom JVM arguments
Two approaches we can consider to run tomact with custom JVM argument values,
1. In the console just before running the startup.bat file, run the following line with required arguments
SET JAVA_OPTS=%JAVA_OPTS% -D[key=value]
eg: SET JAVA_OPTS=%JAVA_OPTS% -Dproj_env=dev
2. Add the following line in catalina.bat file.
JAVA_OPTS=%JAVA_OPTS% -D[key=value]
eg: JAVA_OPTS=%JAVA_OPTS% -Dproj_env=dev
Saturday, 12 July 2008
Wednesday, 9 July 2008
Thursday, 5 June 2008
Spring Spring Spring !!!
Those who want to get a quick glance of Spring container configuration, please follow the link given below. In this video Rod Johnson discusses about the Spring Framework. He explains philosophy behind Spring, configuring the Spring container, XML configuration, new XML configuration namespaces, Annotation-based configuration, automatic component annotation scanning, Spring JavaConfig, mixing configuration types, and Spring 2.5 new features.
http://www.infoq.com/presentations/johnson-configuring-spring
Voca (UK's largest payment processing engine), they have shown the real capability of Spring. We do need to really appreciate the challenges they have taken to achieve the milestones. Wonderful ... Running such a mission critical system extends really the scope of Spring.
http://www.infoq.com/presentations/qcon-voca-architecture-spring
Couple of outstanding tutorials from Willie Wheeler can be found in,
http://wheelersoftware.com/articles/spring-web-flow-2.0.html
Enjoy the feast :)
-
Thursday, 29 May 2008
How old would be the Egyptian Sphinx

We all wonder when we see the Sphinx of Egypt(at Giza). How they might have built some thing like this 4500 years ago (as Egyptologists claim). Yah, it’s a true wonder. It’s indicating us that there was a time when intelligent people lived in this planet. By considering there intelligence, one question really pops up, how much intelligence we developed from that time? Do we have a remarkable progress path? Well, it’s some thing we need to thick.
A large number of people convinced (so far) with the answer to the question, 'When' the Sphinx was built? Still some other questions are really annoying us, WHY they did so? WHO did it? .... No answer for that.
There are people who really not convinced by the age of Sphinx. The helping hand to step up with a different theory for them was the weathering or we can say the erosion characteristics they noticed on the Sphinx. A couple of studies and tests which they carried out indicated a different time, which is far more behind that we can simply assume, more than 9000 years old. Oh GOD! .. Yes. . Even I thought the same.
The main factor forced to believe them in this new way is the erosion characteristics, as I mentioned earlier, which cannot happen just really with the wind that appears in Sahara, but rain . hmm .. Rain in Sahara? yes, but not now ... more than 9000 years ago .. may be even before that. That time the area was very fertile land with enough rain .. even computer model predicts that a time of 10500 years ago, the climatic situation of that land was blessed with rain.
Quite interesting, right?
The patterns they found in the Sphinx clearly gives a clue that the erosion was due to rain. So it means that the Sphinx was built even before? Confusing .. since we don’t have any solid evidence.
You might have heard about the Edger Cayce (the Sleeping prophet of America). Even he mentioned once that the Sphinx is build around 10,500 years ago. If that’s true, we had a great intelligent civilization in this world, it’s amazing isn’t it? .. mystery …
Well, those who really need to know about the mystery of Sphinx, there are some really good documentaries in Youtube.
http://www.youtube.com/watch?v=9J2cKnmTTwE&feature=related
Subscribe to:
Posts (Atom)