java

unicode regular expression tutorial

Any good tutorial available for changing ASCII regular expressions to unicode regular expression? I need to convert existing us english app to support internationalization. ...

Proper way to autowire a Hibernate Session in a Spring Transaction JUnit test

This question is similar to a previous one. I am trying to @Autowire a Hibernate Session in one of my Spring-JUnit-Transactional tests but I am getting this exception: java.lang.IllegalStateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional ... Here is my JUnit class: @RunWi...

Java: How can I require a method argument to implement multiple interfaces?

It's legal to do this in Java: void spew(Appendable x) { x.append("Bleah!\n"); } How can I do this (syntax not legal): void spew(Appendable & Closeable x) { x.append("Bleah!\n"); if (timeToClose()) x.close(); } I would like if possible to force callers to use objects that are both Appendable and Closea...

Why is a JLabel in a JPopupMenu not respecting its Look and Feel?

I have a Java application with a custom defined Look and Feel in which the user can switch between a light and a dark mode. One of the things we have is a right click popup menu that inherits from the JPopupMenu class. The first thing we add to the menu is a JLabel: add( new JLabel( "<html><i> " + field.desc + "</i><br/>field = " + fi...

Connecting error through javamail

I'm trying to connect to james server using imap protocol, but I'm getting following exception: Exception in thread "main" javax.mail.MessagingException: Network is unreachable: connect; nested exception is: java.net.SocketException: Network is unreachable: connect at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:611) at ja...

Shopping Cart Functionality that supports MLM

I am looking to duplicate functionality of a site I frequently use to purchase my own organic food and vitamins (http://www.iherb.com) whereby for users on the first order, they receive $5 off along with free shipping. If you enter the coupon code: GOV193 you get the $5 off. Likewise, you can generate future discounts based on the code...

Struts2 ParametersInterceptor problem with oauth_token

I am developing an application in Struts2 with Twitter4J at GAE/J. I am getting following exception in the GAE log. Unable to understand whats wrong with it. com.opensymphony.xwork2.interceptor.ParametersInterceptor setParameters: ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'oauth_token' on 'class com.a...

Smalltalk compilers that target either Java, .NET or Ruby

Looking for a Smalltalk compiler that given Smalltalk (Instantiations) will emit either Java bytecode, .NET CLR or Ruby. Not looking for porting utilities as I want to leave the application in Smalltalk. I have googled for solutions and ran across a company who had a website (http://www.smalltalkmigrations.com/) but it seems as if they ...

Precise time measurement in Java

Java gives access to two method to get the current time: System.nanoTime() and System.currentTimeMillis(). The first one gives a result in nanoseconds, but the actual accuracy is much worse than that (many microseconds). Is the JVM already providing the best possible value for each particular machine? Otherwise, is there some Java libra...

Tab between fields in TableViewer

What I'd like to do is be able to tab between elements in table. I currently am creating my table like this. this.tableViewer = new TableViewer(parent , SWT.FULL_SELECTION); tableViewer.setUseHashlookup(true); table = tableViewer.getTable(); GridData gridData = new GridData(GridData.FILL_BOTH); ...

Framework to facilitate editable, dynamic, SEO friendly product pages on open source enterprise Java stack?

Let me outline the problem space. I want to create a SEO friendly page that contains dynamic information, but also has areas of information that are easily editable by HTML content editors (NOT programmers) outside of the normal development lifecycle (I'll call this content 'static' content). For example think of a product page that ha...

Java's Representation of Serialized Objects

I'm looking for the format that Java uses to serialize objects. The default serialization serializes the object in a binary format. In particular, I'm curious to know if two runs of a program can serialize the same object differently. ...

Change user.home system property

How do I change the user.home system property from outside my java program, so that it thinks it's a different directory from D:\Documents and Settings\%USERNAME%? Via environment variables, or VM arguments? ...

Scripting (with PHP) in Java?

I'm trying to write a simple Java game. I have a NPC class, with a function Dialog which returns what the npc would say, which would depend on various conditions. I'm thinking that it would probably make sense to offload the logic of deciding what each npc would say to a scripting language, so that it could be changed updated easily. Th...

Tokenize a string with a space in java

I want to tokenize a string like this String line = "a=b c='123 456' d=777 e='uij yyy'"; I cannot split based like this String [] words = line.split(" "); Any idea how can I split so that I get tokens like a=b c='123 456' d=777 e='uij yyy'; ...

Disconnect java application from console/command window

Possible Duplicate: Is there a way to the hide win32 launch console from a Java program (if possible without JNI) When I run my java swing application in a batch file on windows, the console/command window remains open whilst my java application is running. This creates an extra window on my taskbar which I would prefer not to h...

Java serialization, ObjectInputStream.readObject(), check if will block

I'm using an ObjectInputStream to call readObject for reading in serialized Objects. I would like to avoid having this method block, so I'm looking to use something like Inputstream.available(). InputStream.available() will tell you there are bytes available and that read() will not block. Is there an equivalent method for seriailzation...

Why does superclass's method get called instead of subclass's?

I have a base 'node' class with an 'update()' member function now i have other classes that extend the 'node' class and override the 'update' class. but all my 'node's are stored in an array (of type 'node') and they all get 'update'd in turn. The problem is the its calling the base node class update rather than my override function. ...

Struts - Uploading Files

I'm having a problem uploading a file using spring webflow 1.0 and struts 1.3. The jsp is something like this: <html:form action="/flowAction" method="post" enctype="multipart/form-data"> <!-- snip --> <html:file property="file" name="attachDocumentsForm" size="50"/> <!-- snip --> </html:form> The Form is something like t...

Why use an MVC framework when Servlets, JSPs and a lightweight DAO layer will work?

I'm finding it difficult to embrace a Java MVC framework, when it looks as if Servlets, JSPs and a lightweight DAO will do just about everything you need it to do in order to decouple the controllers/views/models. For PHP I can see the necessity since there are no built in constructs like servlets, but do Java MVC frameworks really give ...