java

Most common checked and unchecked Java Exceptions?

As far as I understand, there is no way to find out which Exceptions a method throws without looking up the API docs one-by-one. Since that is no option, I'd like to reverse the research and ask you which are the most common Exceptions and RuntimeExceptions you've come across when dealing with Casting Arrays Vector, ArrayList, HashMap...

Cross platform file compression

We need a cross platform solution for compressing files. Our server runs on Windows XP/Vista/7 and 3 Unix distros, SunOS, HPUX, and AIX. Our server creates files that needed to be zipped before being set back to the client. Our initial thought was to compress the files with jar, as most of the servers have java installed, but apparent...

Tristate Checkboxes in Java

I could really use a tri-stated checkbox in Java. It sounds like a simple thing, but I've only seen really ugly implementations. Three radio buttons just take up too much real estate and will probably be confusing for the users in my case. It's basically for a search dialog. I need true, false or "don't care" options. Is there a dif...

XStream parse JSON with no root node

I am currently deserializing JSON using XStream, and it has been working great. However, when I have JSON string like the following { key1: { an_object: { something: 'foobar' } }, key2: { another_object: { data: 'hi' } } most notably it doesn't have a root node, I'm not sure how to parse it. Basically, I want the opposite of...

ASM bytecode instrumentation for method entry / exit

I've created a JVMTI agent that does the following at a high level: onClassLoadHook send the bytecodes for the loaded class to a separate Java process that will instrument the class using ASM get the bytecodes back and load them In my seperate java process that instruments the loaded Java class I do the following : .. .. cr = n...

Refreshing/replacing beans in the ApplicationContext. Possible or am I missing the point?

First off, I think I'm trying to use Spring incorrectly, but confirmation would be appreciated. I am trying to reset a single bean in mid-application. My initial configuration works just fine. My scenario 1 Insurance Claim bean (session scope) 1 Claim details bean which is a multiactionController (getClaim&setClaim enabled, protot...

Java Implementation of Flash API

Just curious to see people's opinions: Has anyone thought about implementing the Flash player API in Java? Controlling sprites, graphics, media, etc is so easy to do in Flash, it seems like it would only make sense to have a similar API in Java. ...

Has anyone succeded in writing a JMX wrapper around Open Symphony's Quartz?

I'm trying to expose Quartz (that I'm running in Jboss) to the jboss JMX console. I'm not having any luck with said process and am wondering why it's so hard to find any reference materials on doing this. Seems like a pretty useful thing. I'd love some tips on how to get it set up, if anyone has done it. ...

Creating a JFrame from another JFrames constructor

I have 3 objects that extend JFrame let's call them FrameA FrameB FrameC. FrameA is my main application window. From FrameA's constructor if the application is not registered i create FrameB and FrameC. They are just popup's that indicate trial period. 2 times out of 10 application freezes and never shows the B anc C frame and frame A ...

Can't send email using Spring and Quartz

I'm using Spring,Quartz to schedule send email function.But I can't do that This is my error java.lang.NullPointerException at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTr ansport.java:557) at org.springframework.mail.javamail.JavaMailSenderIm pl.doSend(JavaMailSenderImpl.java:382) at org.springframework.mail.javamail.JavaMailSend...

Configuring Java FileHandler Logging to create directories if they do not exist

I'm trying to configure the Java Logging API's FileHandler to log my server to a file within a folder in my home directory, but I don't want to have to create those directories on every machine it's running. For example in the logging.properties file I specify: java.util.logging.FileHandler java.util.logging.FileHandler.pattern=%h/app-...

Conntecting remote tomcat JMX instance using jConsole

I am trying to connect to a remote tomcat JMX instance using jConsole. But can't connect successfully. Any Idea? I included the following option in remote tomcat catalina.sh: JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.port=9004 \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun...

putting hyperlink in <h:messages> tag

I have a requirement where clicking each errors should focus input box. I am trying different ways but could not succeed. I got some answers in the past but that did not work like i wanted. I was using tag with onclick event but I had to do this for each input boxes which is not so relevant if I have 20 fields. So I was looking some t...

what does happen if I call run() method myself?

in the main method if I write this: Thread aThread = new Thread(); aThread.run(); what will happen??? ...

How to create log file in in tomcat/logs folder

Hi all, I'm using log4j to log in application. Now the log file is created in the some location, like j:/logs/mylog.log, I want the log file mylog.log to be created in the tomcat/logs foder. How to set this? Now current log4j property is as follows log4j.appender.fileAppender=org.apache.log4j.DailyRollingFileAppender log4j.appender...

How to obtain object's data by using remote debugging functionality?

I wonder how can I use similar to Eclipse's remote debugging technique to get the data from remote object (that reside on server)? I am already have the client code and just want to extend it to bind (if possible) to some port and get the data from the server. Honestly I don't want to use anything specific on the server side (i.e. cre...

What are the differences between these two ways of starting threads?

If I have a class that implements the Runnable interface, what are the differences between these statements in the main method? MyThread t1 = new MyThread(); t1.start(); and MyThread t2 = new MyThread(); new Thread(t2).start(); ...

How can I get the functionality of `<input type="file" of HTML in Swing?

How can I get the functionality of <input type="file"> of HTML in Java Swing? ...

How to synchronize(d) methods and modify objects' properties within a parent object?

I have two threads running from a controller class. The first thread receives SMS messages and should continue running as long as the program is in the started state. The other thread is used to calculate the units GPS location. The controller launches the SMS thread and waits from a text message. If a text message meets certain criteri...

Dealing with maps, equals() and hashCodes(). How efficient is this ?

I'm writing something which will receive quite a number of transactions per second. For every transaction that comes in, a reference is made to a map which key values are the id and a bean which will help process that particular transaction. Basically each transaction comes in bearing an id, a look up will be done to the map to retrieve ...