java

Spaces in java execute path for OS X

On OS X, I am trying to .exec something, but when a path contains a space, it doesn't work. I've tried surrounding the path with quotes, escaping the space, and even using \u0020. For example, this works: Runtime.getRuntime().exec("open /foldername/toast.sh"); But if there's a space, none of these work: Runtime.getRuntime().exec("o...

Help with a RecordStore Update problem in java j2me?

I have this code that I have shortened to the most important bits that I think affect the outcome but basically I have an error regarding the bytes. I'm not sure why because this code works in a different program as I have borrowed the code. This is meant to extract the data from the record store with the retrieve button then update it w...

Spring MVC, generating a form backing object from a request?

I am using Spring MVC 2.5, and I am trying to get a JSTL form object to load from a GET request. I have Hibernate POJOs as my backing objects. There is one page directing to another page with a class id (row primary key) in the request. The request looks like "newpage.htm?name=RowId". This is going into a page with a form backing object...

Javac flag to disallow raw types?

Is there any Java compiler flag that one can pass to tell the compiler to disallow the use of raw types? That is, for any generic class, let the compiler force that the parameterized version be used, and throw a compilation error otherwise? ...

Eclipse 3.4 and Jboss deployment issue:

I have a problem when trying to deploy my project in JBoss. The generated war file contains the servlet.jar that are part of my dependencies but conflicts with the servlet classes of JBoss. Error ...servlet.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class I can remove the servle...

How can I find the target Java version for a compiled class?

Duplicate: Tool to read and display Java .class versions If I have a compiled Java class, is there a way to tell from just the class file what its target version compatibility is? Specifically, I have a number of class files, compiled to Java 6, which are running under Java 5 and giving the the "Unrecognized version" error. I wan...

Determine Correct Method Signature During Runtime

I am using the following the following class org.apache.poi.hssf.usermodel.HSSFCell, with a list of the following methods: void setCellValue(boolean value) void setCellValue(java.util.Calendar value) void setCellValue(java.util.Date value) void setCellValue(double value) void setCellValue(HSSFRichTextString value) void setCellValue...

How do you format a fractional percentage with java.text.MessageFormat

My percentages get truncated by the default java.text.MessageFormat function, how do you format a percentage without losing precision? Example: String expectedResult = "12.5%"; double fraction = 0.125; String actualResult = MessageFormat.format("{0,number,percent}", fraction); assert expectedResult.equals(actualResult) : actualResult ...

Need an elegant way to invoke arbitrary code on a specified interval

Ok, I have a game server running in Java/Hibernate/Spring/Quartz. The game clock ticks with a Quartz timer, and that works just fine. However, I have many other things that need to happen at specific, tweakable intervals (in game time, not real time). For instance, every 24 hours game time (~ 47 minutes real time, depending on the ser...

Fast pixel plotting using SWT?

I'm looking for a fast and easy way to plot arbitrarily colored pixels in an SWT Canvas. So far I'm using something like that: // initialization: GC gc = new GC(canvas); // inside the drawing loop: Color cc = new Color(display, r, g, b); gc.setForeground(cc); gc.drawPoint(x, y); cc.dispose(); This is horribly horribly slow. it takes ...

Why does ConcurrentHashMap prevent null keys and values?

The JavaDoc of ConcurrentHashMap says this: Like Hashtable but unlike HashMap, this class does not allow null to be used as a key or value. My question: why? 2nd question: why doesn't Hashtable allow null? I've used a lot of HashMaps for storing data. But when changing to ConcurrentHashMap I got several times into trouble because...

How important is French when working in France coding Java?

I am looking into the possibility of working in IT in France - I currently work remotely for a UK company, but live in France, and speak French reasonably well (my native language is English). The problem I have is that I have no technical French, and am wondering how important French is, working in IT in France (Java programming specif...

How do I build a HTML table from Glazed List?

Lat week I downloaded the Glazed List library into eclipse. I have been looking through the tutorials and it seems that everything is designed to run jTable or SWT. I am need a backing list(Map, table, whatever) for simple HTML tables that can be sortable. I have been doing this by rolling my own classes to create HTML tables from either...

firePropertyChange on Sequence generated Id

Hi there, When calling persist the setId method never gets called which in turns causes the firePropertyChange not to execute. I need to fire the changeSupport method because I have functionality that dependants on the state of my entity. public void setId(Long id) { Long oldId = this.id; this.id = id; changeSupport.firePro...

Hibernate uses initial WHERE clause in subsequent queries

In using Hibernate's JPA implementation, I noticed an interesting optimization behavior. Within the same transaction, the initial JPA query's WHERE clause is used for subsequent queries involving the results of the initial query. For example, person has lastName and a set of owned books. // (1) get person by last name Query q = entityM...

applet fails to load class from jar

Some users are complaining that the applet no longer works, When they view the java console they are greeted with a java.lang.noClassDefFoundError and checking my access log's I see they have downloaded the jar file that contains the class, and then issue a get request for the particular class. Different users break on different classes...

Oracle Datasource returning null connection

The oracle data source is returning null connection when the no of connection request is more. I have the implict cache enabled.The oracle specs says null is returned only is ConnectionWaitTimeout is set. I do not have a value set for ConnectionWaitTimeout in the cache properties. This is what the spec says about ConnectionWaitTimeout...

hibernate object vs database physical model

Is there any real issue - such as performance - when the hibernate object model and the database physical model no longer match? Any concerns? Should they be keep in sync? Our current system was original designed for a low number of users so not much effort was done to keep the physical and objects in sync. The developers went about ...

Checking if a ClientSocket has disconnected in java hangs.

This is a follow up to: this question Basically, I have a server loop that manages a connection to one solitary client. At one point in the loop, if a ClientSocket exists it attempts a read to check if the client is still connected: if (bufferedReader.read()==-1 ) { logger.info("CONNECTION TERMINATED!"); clientSocket.cl...

Is there a way to search for and access Threads that are currently running?

Using Java 6: I have a method that uses a Thread to run a task in the background. This task accesses files, so the method should not be able to have multiple threads running. I am trying to figure out if there is a way that I can search for active Threads at the beginning of my method. I want to know if there is an active Thread that i...