java

regular expression to replace two (or more) consecutive characters by only one?

In java, which regular expression can be used to replace these, for example: before: aaabbb after: ab before: 14442345 after: 142345 thanks! ...

What Does OSGi Solve?

I've read on wikipedia and other sites about OSGi, but I don't really see the big picture. It says that it's a component based platform, and that you can reload modules at runtime. Also the "practical example" given everywhere is the Eclipse Plugin Framework. My questions are: 1) What is the CLEAR and SIMPLE definition of OSGi? 2) Wha...

How can I best connect Seam and GWT in a stateful web application?

We have a web application that was implemented using GWT. What it presents is fetched from a Jboss/Seam server using the remoting mechanism, and this works fine. However, the application is now extended to support sessions and users. The Seam GWT service doesn't seem to provide a way to let me log in such that Seam can return restricted ...

How do I find out what type each object is in a ArrayList<Object>?

I have a ArrayList made up of different elements imported from a db, made up of strings, numbers, doubles and ints. Is there a way to use a reflection type technique to find out what each type of data each element holds? FYI: The reason that there is so many types of data is that this is a piece of java code being written to be implem...

Add non-ASCII file names to zip in Java

What is the best way to add non-ASCII file names to a zip file using Java, in such a way that the files can be properly read in both Windows and Linux? Here is one attempt, adapted from https://truezip.dev.java.net/tutorial-6.html#Example, which works in Windows Vista but fails in Ubuntu Hardy. In Hardy the file name is shown as abc-ЖДФ...

Can Spring Parse and Inject Properties Files?

I already know how to: Load properties files into my Spring configuration using: <context:property-placeholder location="aaa/bbb/ccc/stuff.properties"/> Build properties objects on the fly using: <props><prop key="abc">some value</prop></props> But what I cant do, and would be really useful, is to have Spring load a properties fil...

using JTables with netbeans 6.1 aka Matisse

Before you answer: Yes I have read the jtable tutorial over at Sun. No, it did not help me. Yes, I am a dolt. Please don't answer with a reference to that document. What I am specifically interested in is how to dynamically add rows and columns to my Jtable via the Netbeans IDE. I already have an object that contains a hashmap with my da...

Do you ever use the volatile keyword in Java?

In work today, I came across the volatile keyword in Java. Not being very familiar with it, I found this explaination: http://www.ibm.com/developerworks/java/library/j-jtp06197.html Given the detail in which that article explains the keyword in question, do you ever use it or could you ever see a case in which you could use this keyword...

Can Seam 2.0.2sp1 apps run on Tomcat 5.5.9 with JBoss Embedded?

I'm trying to run the Tomcat with JBoss Embedded jpa booking example. I run the build and deploy the war. I then get the following error: ERROR [catalina.core.ContainerBase.[Catalina].[localhost].[/jboss-seam-jpa]] Error configuring application listener of class com.sun.faces.config.ConfigureListener java.lang.NoClassDefFoundError: j...

How can I give java.util.Random a specific seed in thirdparty classes?

I have a Java program that loads thirdparty class files (classes I did not write) and executes them. These classes often use java.util.Random, which by default generates random starting seed values every time it gets instantiated. For reasons of reproducability, I want to give these classes the same starting seed every time, changing it ...

Standard concise way to copy a file in Java?

It has always bothered me that the only way to copy a file in Java involves opening streams, declaring a buffer, reading in one file, looping through it, and writing it out to the other steam. The web is littered with similar, yet still slightly different implementations of this type of solution. Is there a better way that stays within...

what is j2ee/jee?

OK stupid question but... I realize that literally it translates to java 2 enterprise edition. What I'm asking is what does this really mean? when a company requires j2ee experience what are they really asking for? experience with ejb's? experience with java web apps? I suspect that this means something different to different peopl...

Does WCF play well with Java?

Which of the WCF Service Protocols work well with Java? Do the TCP Service Bindings work with java remoting (either Corba, EJB, JMS, etc.)? What about the WebServices exposed as Service EndPoints. Have these been tested against the common Java WebServices stack for interoperability? ...

Licensing: Apache Commons vs. the OpenJDK license

Now that Java is OpenSource do their respective licenses enable or encumber a merge? ie: Are the licenses of the Apache Commons and OpenJDK licenses compatible enough to codebases into say OpenJDK 8? RE-DIRECT: Having taken onboard Cowan's response I have created two threads, one for each license, to explore how to achieve s...

Why is my Java program leaking memory when I call run() on a Thread object?

(Jeopardy-style question, I wish the answer had been online when I had this issue) Using Java 1.4, I have a method that I want to run as a thread some of the time, but not at others. So I declared it as a subclass of Thread, then either called start() or run() depending on what I needed. But I found that my program would leak memory ov...

Is there any 'no of lines code' limit for a java class ?

How many lines of code can we write in any java file ? Does it depend on JVM ? ...

How do you diagnose a leak in C memory caused by a Java program?

I'm working on a large application (300K LOC) that is causing a memory leak in the Sun 1.6 JVM (1.6_05). Profiling the Java shows no leak. Are there any diagnostics available from the JVM that might detect the cause of the leak? I haven't been able to create a simple, isolated Java test case. Is the only way to figure this out by using a...

Hibernate 3: unable to query PostgreSQL database

I am setting up a project using Hibernate 3.3.1 GA and PostgreSQL 8.3. I've just created a database, the first table, added one row there and now configuring Hibernate. However, even the simplest query: Criteria criteria = session.createCriteria(Place.class); List result = criteria.list(); could not be executed (empty list is returne...

Best way to extract a timezone from a mail Date header in Java?

I need to store the timezone an email was sent from. Which is the best way to extract it from the email's 'Date:' header (an RFC822 date)? And what is the recommended format to store it in the database (I'm using hibernate)? ...

Sun Certified Web Component Developer exams

Hi I was just wondering does anyone know if there any massive differences in the SCWCD 1.4 exams and the 1.5 exams? Also does anyone know of any good urls or pdf's that can be used to study for this exam ...