java

Examples of how to add an iterator to a custom class in Java 1.4?

Could someone give me an example of the best way to add an iterator to a custom class pre Java 5's iterable interface? Would wrapping a Collection be the best option? Something like public Iterator iterator() { return wrappedCollection.iterator(); } In my initial post I confused Iterator with Iterable. The end result I am interes...

Finding Struts version?

What is the easiest way to find the Struts library version? I'm adding Struts libraries to an generic eclipse project, and need to be able to differentiate between versions. (Other libraries like Spring have a getVersion() call) I can always read the jar manifest, but I'm looking for an easier way. ...

Servlet page decoration: Do people use Tiles, Sitemesh, or something else?

I've used Tiles and Sitemesh for a number of years and while I personally prefer the Sitemesh style page decoration, I generally don't see a lot of mention of Sitemesh or Tiles on the Internet. Do people use Tiles and/or Sitemesh actively, or are there other libraries that have taken over in this capacity? ...

Javascript_Java_Interaction applet "Codebase" problem

I saw an article about Javascript_Java_Interaction today at : http://www.rgagnon.com/javadetails/java-0184.html [ You can try the working version on that site ] So I tried it on my PC, after some simple format change the files look like this : ========================================================================================...

Can I replace groups in Java rexex?

I have this code, and I want to know, if I can replace only groups (not all pattern) in Java regex. Code: //... Pattern p = Pattern.compile("(\\d).*(\\d)"); String input = "6 example input 4"; Matcher m = p.matcher(input); if (m.find()) { //Now I want replace group one ( (\\d) ) with number //and group two...

Accessing Liferay web content from inside a portlet?

I have a Struts portlet being used in a Liferay Portal environment. I have been localizing my resource strings using standard resource files so far. I can access the message bundle from my portlet using the <bean:message> tag, and it works great. So for example, in a form I might have the following label defined in my JSP file. ... <lab...

JTabbedPane weird behaviour

I have the following code : JTabbedPane container; ... AWindow page = WinUtils.buildWindow(); boolean existing = checkIfExists(page); // in this code, this will always be false if(!existing) { String tabName = page.getLoadedFileLocation().getName(); container.addTab(page.getLoadedFileLocation().getName(), page); } Component com...

What's the best way to share JARs across multiple projects?

When you have multiple projects that all use the same set of JAR libraries, it's tedious to include the same JARs over and over again with each project. If I'm working on 20 different projects, I'd rather not have 20 of the same exact set of JAR files lying around. What's the best way to make all those projects (and new projects as well)...

App to read form document (scantron-ish)

Hi all, I need to create form that will be filled in by hand and read digitally. I plan on using a sort of scantron-esque format with rows and columns that the user can just color in the a circle in the appropriate cell and the computer will know that value based on the xy position in the cell matrix. Like an excel address. | S...

YUI Uploader with Java back-end

I am trying to use the (flash based) YUI Uploader with a Java (Spring-based) back-end. The typical way of uploading files in the Java Servlet world is to set the ENCTYPE='multipart/form-data' on the HTML form requesting the file from the user. With the right server side APIs (i.e. Commons FileUpload), it is possible to get the file on t...

scripting in java - javascript from a server-side class file in Java 1.5

I have three types of get requests that are delivered to a class file on web application from a mobile device. Because the mobile device provides no cookies, the log file hit only has in.ter.nal.ip ser.ver.i.p:port 2009-06-05 09:14:44 GET /applicationname/mobiledevicexml reqtype=login&userid=xx### 200 87 - MercuryMobile/1.0 CFNetwork...

Backward Compatible in xstream

I am using nice little piece of xstream to perform serialization. I have the following class : // version 0 class A { } // version 1 class A { Object o = new Object(); } In order for me to read version 0 xml file to construct version 1 class A, I will have to add the following method in version 1 class A : class A { private...

Efficient way to find "matches" in a matrix in java

I have an existing (java) application that models an order book, as it stands each order is visible to every other. There is now a requirement to put (what is effectively) a per order ACL in place. An example to illustrate, lets say I have access groups [V-Z] and orders [A-F] A B C D E F V 1 0 0 1 1 0 W 0 1 1 0 0 1 X ...

Is it possible to redirect a url to another using a webproxy ( such as fiddler )

I'm trying to parse a WSDL file which is in another server but has hard codded "localhost" all over the document. When I fetch it, obviously the program complains "connection refused" because nothing is running in my machine. My question is: Is it possible to use a webproxy ( such as fiddler ) to redirect those localhost request to m...

what is the best way to use dates with java swing

what i want to do is having like the java script popup date chooser in my application. i am using java swing and would like to avoid any input mistakes by the user. specifying a format is easy to implement but not user friendly for the user. what are your suggestion ? any libraries? ...

Parsing java main args[] array errors

Hello I'm stuck on a simple Java exercise, I hope someone can help. Sorry if this is really simple I'm a java newbie. What I'm having trouble with: if the user enters a string other than "help" such as "foo" then I get the following error: Exception in thread "main" java.lang.NumberFormatException: For input string: "foo" at java.la...

How can I cache the marshalled SOAP XML generated by Apache CXF for a particular Java Object to improve performance?

In my application, we have a webservice method called getFoo() which returns a Foo object. The getFoo() method is called several hundred times a second. The Foo object is Marshalled from our Java object to the SOAP XML response using Apache CXF. From profiling our application, we determined that the marshalling of this object (java ...

Maven release properties

When we release projects it is usually the same every time. Are there any arguments or properties that I can add to release:prepare that will allow for pattern releasing in batch mode? Example: What is the release version for "MyProject"? (company.jar.site:myproject) 0.0.1: : What is SCM release tag or label for "MyProject"? (company...

charting platform

Looking for options for a live, large data set charting platform to deal with large quantity of constantly evolving data and display it via browser in an usable manner. Would need to be based off of a DB backend vs. the "reads XML file" approach of some of the Flash apps. ...

Why aren't variables in Java volatile by default?

Possibly similar question: http://stackoverflow.com/questions/106591/ Today I was debugging my game; It had a very difficult threading problem that would show up every few minutes, but was difficult to reproduce. So first I added the synchronized keyword to each of my methods. That didn't work. Then I added the volatile keyword to ever...