java

How can I use InvokeListener in tapestry5?

How can I convert this code <span jwcid="permissionInEachStep@InvokeListener" listener="listener:onEditPermissionInEachStep"/> into tapestry5 or have a different way to invoke method? ...

Access levels of java class members

I realise that this is a very basic question, but it is one which has always bothered me. As I understand things, if you declare a field private in Java then it is not visible outside of that class. If it is protected then it is available to inherited classes and anything in the same package (correct me if either of those definitions is ...

Java ReentrantReadWriteLocks - how to safely acquire write lock?

I am using in my code at the moment a ReentrantReadWriteLock to synchronize access over a tree-like structure. This structure is large, and read by many threads at once with occasional modifications to small parts of it - so it seems to fit the read-write idiom well. I understand that with this particular class, one cannot elevate a re...

Converting transparent gif / png to jpeg using java

I'd like to convert gif images to jpeg using Java. It works great for most images, but I have a simple transparent gif image: [In case the image is missing: it's a blue circle with transparent pixels around it] When I convert this image using the following code: File file = new File("indexed_test.gif"); BufferedImage image = ImageIO...

"unmappable character for encoding" warning in Java

I'm currently working on a Java project that is emitting the following warning when I compile: /src/com/myco/apps/AppDBCore.java:439: warning: unmappable character for encoding UTF8 [javac] String copyright = "� 2003-2008 My Company. All rights reserved."; I'm not sure how SO will render the character before the date, but it ...

Can you recommend a Java Decompiler and UI for Linux ?

I am looking for a Java decompiler like DJ Java Decompiler but that runs natively on Linux. (Ubuntu/Hardy/64). Can you recommend one ? ...

Best way to build a Plugin system with Java

How would you implement a Plugin-system for your Java application? Is it possible to have an easy to use (for the developer) system which achieves the following: Users put their plugins into a subdirectory of the app The Plugin can provide a configuration screen If you use a framework, is the license compatible with commercial develop...

How can I have somehing like the html file button to browser in file in JAVA swing?

I am trying to create my first UI page though Swing. In this page I wish to browse for a file. Can someone please help me achieve this? ...

Lucene Sentence Search

Is it possible to search for a phrase of the kind Searching is fun, in Lucene? When I try to search with this, Lucene ends up looking for the word fun alone. ...

Weird JDBC executeQuery exception

I have the following code: public Object RunQuery(String query) throws Exception{ System.out.println("Trying to run query"); Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); System.out.println("Got Statement"); rs = stmt.executeQuery(query); System.out.prin...

JDBC Wrapper tutorial - is it still relevant?

This article from IBM about a JDBC wrapper seems good and I'm tempted to use it: http://www.ibm.com/developerworks/java/library/j-jdbcwrap/index.html but it its dated 2001 - is it still relevant to today's best practices or has this been superseded by something else better? Your opinions are much appreciated. ...

Jfreechart selection

Is there a way to be able to click on a segment on a plot and have jfreechart tell me the x/y coordinates of that point or somehow return the corresponding data associated with that line? Does jfreechart have any packages at all for interacting with the plot? ...

Which open-source java-library provides an easy way to read and write ESRI Shapefiles?

For a project I need to read and write ESRI shapefiles. It should be very easy, as I don't need advanced features. Is something out there? ...

Java sockets

I have implemented some remote method invocation using sockets opened on 127.0.0.1. During programs run, computers public IP address changes, because my program connects to net via GPRS modem from time to time. Can you tell me how does that affect my opened sockets? Java version is 1.3, windows platform. There are several network interf...

Best XML format for log events in terms of tool support for data mining and visualization?

We want to be able to create log files from our Java application which is suited for later processing by tools to help investigate bugs and gather performance statistics. Currently we use the traditional "log stuff which may or may not be flattened into text form and appended to a log file", but this works the best for small amounts o...

Use of the String(String) constructor in Java

I've read on articles and books that the use of String s = new String("..."); should be avoided pretty much all the time. I understand why that is, but is there any use for using the String(String) constructor whatsoever? I don't think there is, and don't see any evidence otherwise, but I'm wondering if anyone in the SO commmunity know...

Determining which submit button was used?

Is it possible to determine which submit button was used? I have a confirmation form with 2 submit buttons. The first would confirm the order, do some DB tasks, then redirect. The second, which is a Cancel button, will just redirect to the same page, without doing any DB tasks. Is it possible in the servlet, preferably via the reques...

Throwing exceptions to control flow - code smell?

Consider this code (Java, specifically): public int doSomething() { doA(); try { doB(); } catch (MyException e) { return ERROR; } doC(); return SUCCESS; } Where doB() is defined as: private void doB() throws MyException Basically, MyException exists only in case doB() meets some condition (which is not cat...

Regex in java question, multiple matches

I am trying to match multiple CSS style code blocks in a HTML document. This code will match the first one but won't match the second. What code would I need to match the second. Can I just get a list of the groups that are inside of my 'style' brackets? Should I call the 'find' method to get the next match? Here is my regex pattern...

Draw offscreen with JOGL

As part of a larger project I'm trying to implement a facility using JOGL that will export 3D renderings to bitmap formats. We do this by creating a GLJPanel and drawing the scene we want to it, then extracting the bitmap. This all works fine as long as the system has at least one visible window on the screen - not necessarily the window...