java

Regex Named Groups in Java

It is my understanding that the java.regex package does not have support for named groups (http://www.regular-expressions.info/named.html) so can anyone point me towards a third-party library that does? I've looked at jregex but its last release was in 2002 and it didn't work for me (admittedly I only tried briefly) under java5. ...

Read only spinner

I am learning Jsf.Is there any method for making the spinners read only?I should change the value only using spinners and not directly typing the number.Can i implement that by setting attribute in the spinners.tld file? ...

Why are local variables not initialized in Java?

Was there any reason why the designers of Java felt that local variables should not be given a default value? Seriously, if instance variables can be given a default value, then why can't we do the same for local variables? And it also leads to problems as explained in this comment to a blog post... ...

Dynamic loading of modules in Java

In Java, I can dynamically add stuff to classpath and load classes ("dynamically" meaning without restarting my application). Is there a known framework/library which deals with dynamic loading/unloading of modules without restart? The usual setup, especially for web-apps, is load balancer, several instances of application, and gradual ...

SQL query statement to retrieve records having CLOB data from the oracle database.

I tried this code and the value of comments from final table having a clob datatype is null or sometimes displays few words. What should I add so that I retrieve the whole data from comments and displays to the textarea? Thanks:-) <%@ page import="java.sql.*" %> <% Class.forName("oracle.jdbc.driver.OracleDriver"); %> <HTML> <TIT...

Are AS (with EJBs) the only way for JEE client/server communication?

Imagine a Java client/server ERP application serving up to 100 concurrent users, both web and swing clients. For persistence we can use Persistence API and Hibernate. But when it comes to client/server communication, do we really have an alternative to using an AS with EJBs to keep down the programming costs of remote communication? It...

How to preview a file on the server in JBoss

I need some ideas on how I can best solve this problem. I have a JBoss Seam application running on JBoss 4.3.3 What a small portion of this application does is generate an html and a pdf document based on an Open Office template. The files that are generated I put inside /tmp/ on the filesystem. I have tried with System.getProperties("...

How can I get the ServletRequest object from within an XFire AbstractHandler's invoke() method?

I'm using XFire as the Web Services provider for Spring Remoting. I'm using an AbstractHandler to authenticate the SOAP request. The idea is to identify the request by the originating server's domain and an API key (a-la Google Maps). The only problem is that I can't seem to find a way to fetch the ServletRequest object from within the i...

What is the purpose of long, double, byte, char in Java?

So I'm learning java, and I have a question. It seems that the types int, boolean and string will be good for just about everything I'll ever need in terms of variables, except perhaps float could be used when decimal numbers are needed in a number. My question is, are the other types such as long, double, byte, char etc ever used in no...

Generate MD5 hash in Java

Is there any method to generate MD5 hash of a string in Java? ...

How to create a deep unmodifiable collection?

I often make a collection field unmodifiable before returning it from a getter method: private List<X> _xs; .... List<X> getXs(){ return Collections.unmodifiableList(_xs); } But I can't think of a convenient way of doing that if the X above is itself a List: private List<List<Y>> _yLists; ..... List<List<Y>> getYLists() { return ...

What is the best way to find specific tokens in a string (in Java)?

I have a string with markup in it which I need to find using Java. eg. string = abc<B>def</B>ghi<B>j</B>kl desired output.. segment [n] = start, end segment [1] = 4, 6 segment [2] = 10, 10 ...

Can I place lot of CPU and IO intensive code in ShutDown Hook

Hi, I am having lot of CPU and IO intensive code in shutdown hook. Some times I see they are not getting executed properly. So Is there any limitation like we should not have lot of code in shutdown hook. Thanks D. L. Kumar ...

Groovy, Netbeans and Java EE

Hello everyone, I want to develop a web application (no frameworks) mixing java with groovy. I am using the IDE Netbeans with the plugin. If I start a new Java SE project and add a groovy class, it works with no problems.. but when I create a new java EE project and add a groovy class it can't compile and shows me the following error: ...

In Java critical sections, what should I synchronize on?

In Java, the idiomatic way to declare critical sections in the code is the following: private void doSomething() { // thread-safe code synchronized(this) { // thread-unsafe code } // thread-safe code } Almost all blocks synchronize on this, but is there a particular reason for this? Are there other possibilities? Are ther...

JPA map collection of Enums

Is there a way in JPA to map a collection of Enums within the Entity class? Or the only solution is to wrap Enum with another domain class and use it to map the collection? @Entity public class Person { public enum InterestsEnum {Books, Sport, etc... } //@??? Collection<InterestsEnum> interests; } I am using Hibernate JPA...

sorted collection in java

I'm a beginner in Java. Please suggest which collection(s) can/should be used for maintaining a sorted list in Java. I have tried Map and Set but they weren't what I was looking for. ...

Java file locking on a network

This is perhaps similar to previous posts, but I want to be specific about the use of locking on a network, rather than locally. I want to write a file to a shared location, so it may well go on a network (certainly a Windows network, maybe Mac). I want to prevent other people from reading any part of this file whilst it it being written...

Java Interfaces?

I really need help with interfaces in general... Any resources that you guys would recommend me? Related: How are Java interfaces actually used? Java interface and inheritance Java Interface Usage Guidelines — Are getters and setters in an interface bad? Why can’t I define a static method in a Java interface? ...

What does the JRE consist of ?

i know that the JDK consists of all java packages .But what does the JRE consist of apart from java.exe ? I could understand the necessities of things in 'bin' folder in the JRE but what about the 'lib' folder ? ...