java

log4j and the thread context classloader

I'm a newbie to Java and just starting to figure out the concept of class loaders. Right now I am having some issues with log4j regarding its use of the thread context classloader. I'm getting the following errors: A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable. The class "org.apa...

Java String split regex not working as expected.

The following Java code will print "0". I would expect that this would print "4". According to the Java API String.split "Splits this string around matches of the given regular expression". And from the linked regular expression documentation: Predefined character classes . Any character (may or may not match line terminators) Therefor...

How to use JFileChooser.showOpenDialog() in a non component class ?

Hello, I have a Java GUI project containing a JMenuBar and I just added a JToolBar. In the previous version, the events were implemented in the same class that extends the JMenuBar. I found it lame and moved the events in another class that extends AbstractAction. My aim is to centralize all the common events to make them react to diffe...

Serialization Proxy with XMLEncoder/Decoder

Hi everyone! How can I implement a Serialization Proxy that can be used with a XMLEncoder/Decoder? The classic one (the Bloch one, I mean) doesn't work... ...

array iterating

I have the following xml format ,which i am parsing and getting the data and storing in an bean called xyz which has testurl as anotherbean xyz has testurl bean an array ,test url bean has id and image <xyz> <testUrl Id="SmallLogo">smallLogo.jpg</testUrl > <testUrl Id="MediumLogo">mediumLogo.jpg</testUrl > <testUrl Id="LargeLo...

jboss 4.2.2 to 5.0.1 migration:needed jboss client jar files

im switching jboss 4.2.2 to 5.0.1 and i have installed jboss. now on client side i replaced existing jar files. jbossall-client.jar,jboss-client.jar,commons-logging.jar,jboss-serialization.jar,jnp-client.jar. but still error came on logging. java.lang.NoClassDefFoundError: org/jboss/logging/Logger at org.jnp.interfaces.NamingCont...

Where to download jdk 1.4.2 for Windows

From where can I download Sun JDK 1.4.2 for Windows. I have checked Sun's website and since they have stopped the support to this version it is no longer available for download. ...

Prevent session timeout on big uploads

Pretty obvious from the title I guess :) Well, problem is that if user is uploading a big file, his session might timeout in that time. How could I prevent session timeouts? I am using Struts2 with AjaxUpload. ...

Spring MVC and annotated controllers issue:

I'm having a strange issue with annotated controllers and Spring MVC. I was trying to use Annotated controllers for the sample MVC application that Spring ships with its documentation. I used 2.5 version. When I specify @RequestMapping at type level, I get "HTTP ERROR: 500 No adapter for handler [Controller class name]: Does your handle...

Flex file upload with HTTPS and JAAS ?

We're trying to upload a file from a flex client to a JEE app. In a full HTTPS environment JEE server is JBoss 5 Using BlazeDS 'Custom' authentication (username and password are entered trhough a flex form) Using BlazeDS per session authentication In regular AMF calls, we can access user principal and use role mecanism. However, in ...

Which Dependency Injection mechanism in Java EE 6 should I use?

Java EE 6 offers (at least) two Dependency Injection mechanisms: DI annoations from Java EE 5 like @EJB, @PersistenceContext, @Resource ... and the new JSR 330. Can I replace the "old" DI annotations with the more general JSR 330 annotations? Are there any benefits or drawbacks of the one or other approach? Which one would you use and w...

Efficient mapping of Strings to ints in Android

Currently I'm using a HashMap to map the strings to int and the int values need to be frequently accessed. I'm looking for a better way to do this if possible with minimal object creation, and preferable being able to store the values as primitive ints without wrapping them with the Integer class. (Basically, the reverse of the SparseArr...

Loading a Java class with native code dependency.

I'm writing a program that loads all the classes from a specified folder. Some of the classes are creating objects in static block and these objects in turn are making some native calls during their creation. Since I do not have the native library I'm seeing a java.lang.UnsatisfiedLinkError Here is a example scenario. Class A extend...

Getting real-time market/stock quotes in C#/Java

Hey, I would like to make an program that acts like a big filter for stocks. To do so, I need to have real-time (or delayed) quotes from the market. I started getting stock quotes by requesting pages from yahoo, accordingand parsing the html to the ticker, and parsing the html. I was wondering how to do this requesting and parsing html....

How can I add an icon to the title bar of a BlackBerry app?

I'm writing a BlackBerry app in Java using the BlackBerry Java API (OS 4.7 and above). I would like to add an icon to the title row of my app. The API documentation says that the method "setTitle" of the "MainScreen" class takes a "Field", so I thought I could just create a "HorizontalFieldManager" that contains an icon (BitmapField) and...

Creating an API in Java for the first time

I am a novice in Java. I have been given the task to design a list of APIs to be used by a GUI to communicate with an application. Considering that the application has just been designed and I have its initial class diagram, should I: 1- Just list the fields and methods from this application class diagram that will be needed by the GUI...

How can I display a JFreeChart in web browser with Stripes Framework

This is the situation: My 'metrics.jsp' page submits a couple variables that are needed to create the chart. The 'ProjectActionBean.java' calls down to a few other java classes that create the JFreeChart. I can display the chart in a pop-up but I want it to be displayed in the original browser window. JFreeChart placeChart = ChartFacto...

Android - create a service that runs once a day

I'd like to create a service for Android that performs an operation once a day at a given time. What's an efficient way to accomplish this - I want to make sure I'm not draining the device battery since this service is idle 99% of the time. ...

Is there a common Data Structure that represent a Map of Lists in Java

I'm looking for a common data sctructure that has the capabilities of a Map<K, List<V>> Currently what I do is something like public class MapOfLists <K,V>{ private Map<K, List<V>> map = new HashMap<K, List<V>>(); public void addItem(K key, V value){ if(!map.containsKey(key)){ map.put(key, new ArrayList<...

XML + Write to Relative Path

I have the following folder structure TempProj !-js !-jsp !-WEB-INF !-classes !-lib Inside my lib folder, I have a java file that creates an XML file, I actually need the file to be generated inside the jsp folder. I'm creating using StreamResult result = new StreamResult("test.xml"); I've tried giving the following paths "../....