java

JPA/Hibernate store date in UTC time zone

How can I configure JPA/Hibernate to store a date/time in the database as UTC (GMT) time zone? Consider this annotated JPA entity: public class Event { @Id public int id; @Temporal(TemporalType.TIMESTAMP) public java.util.Date date; } If the date is 2008-Feb-03 9:30am Pacific Standard Time (PST), then I want the UTC t...

What java web framework best accomodates web ui designers?

What Java web framework out there best supports a role of "web UI designer", that is, lets you: Use popular web design tools (xhtml validators, css editors, what have you) on your views/pages View changes without running on a server Rapidly prototype different UI options Supports a (somewhatly) clean separation between "developer" and ...

is there a simple way to convert my XML object back to String in java?

I have an xml document object that I need to convert into a string. Is there as simple way to do this? ...

What charset does Microsoft Excel use when saving files?

I have a Java app which reads CSV files which have been created in Excel (e.g. 2007). Does anyone know what charset MS Excel uses to save these files in? I would have guessed either: windows-1255 (Cp1255) ISO-8859-1 UTF8 but I am unable to decode extended chars (e.g. french accentuated letters) using either of these charset types. ...

Java equivalent of unsigned long long?

In C++, I enjoyed having access to a 64 bit unsigned integer, via unsigned long long int, or via uint64_t. Now, in Java longs are 64 bits, I know. However, they are signed. Is there an unsigned long (long) available as a Java primitive? How do I use it? ...

Why must delegation to a different constructor happen first in a Java constructor?

In a constructor in Java, if you want to call another constructor (or a super constructor), it has to be the first line in the constructor. I assume this is because you shouldn't be allowed to modify any instance variables before the other constructor runs. But why can't you have statements before the constructor delegation, in order t...

Multidimensional array in Python

Hi, I have a little Java problem I want to translate to Python. Therefor I need a multidimensional array. In Java it looks like: double dArray[][][] = new double[x.length()+1][y.length()+1][x.length()+y.length()+3]; dArray[0][0][0] = 0; dArray[0][0][1] = POSITIVE_INFINITY; Further values will be created bei loops and written into the...

Difference between parseInt and valueOf in java?

What's the difference between these two methods? They appear to do exactly the same thing to me (also goes for parseFloat(), parseDouble(), parseLong() etc, how are they different from Long.valueOf(string) ? Edit: Also, which of these is preferable and used more often by convention? ...

How to plot large data vectors accurately at all zoom levels in real time?

I have large data sets (10 Hz data, so 864k points per 24 Hours) which I need to plot in real time. The idea is the user can zoom and pan into highly detailed scatter plots. The data is not very continuous and there are spikes. Since the data set is so large, I can't plot every point each time the plot refreshes. But I also can't jus...

Fastest way to create a Java message dialog (swing/awt/other)?

I'm creating a Java application that will do some processing then needs to display a message to give the user feedback. However, it appears to be incredibly slow - taking over two seconds to return. I stripped the source down to the apparent culprit, and here is the code used: package SwingPlay; import javax.swing.JFrame; public cla...

java.awt.HeadlessException - Applet not displayed - Part 2

This is with reference to question java.awt.HeadlessException - Applet not displayed. http://stackoverflow.com/questions/445049/java-awt-headlessexception-applet-not-displayed The HeadlessException went away after I added "export DISPLAY=:0.0" in tomcat's startup.sh file. Now some part of the code is run on a batch server which is a sep...

Absence of property syntax in Java

C# has syntax for declaring and using properties. For example, one can declare a simple property, like this: public int Size { get; set; } One can also put a bit of logic into the property, like this: public string SizeHex { get { return String.Format("{0:X}", Size); } set { Size = int.Parse(value,...

Java concurrency cynicism gone too far?

I was wondering if some of you who are experienced in concurrency programming could help me interpret a statement/philosophy properly. I have a copy of Bruce Eckel's grand tome Thinking In Java (4th ed) which has some fairly good coverage of a number of areas of Java which are kind of difficult for beginners to get into. I really enjoye...

RE: Big XML file

Followup question to Big XML File: First thanks a lot for yours answers. After… what I do wrong? This is my class which uses SAX: public class SAXParserXML extends DefaultHandler { public static void ParcourXML() { DefaultHandler handler = new SAXParserXML(); SAXParserFactory factory = SAXParserFactory.newInstance(); ...

Casting to Unknown Type When Class Name as a String

public class ExampleClass { public static void main(String[] args) { // TODO Auto-generated method stub Horse hr1 = new Horse(); Horse hr2 = new Horse(); Horse hr3 = new Horse(); Horse hr4 = new Horse(); Set hrSet = new HashSet(); hrSet.add(hr1); hrSet.add(hr2); hrSet.add(hr3); hrSet....

Basic question about servlet mapping

Hi, I am new to J2EE and related stuff in general. I am trying to move a particular web application from a Sun One server deployment on to JBoss. The application is filled with a lot of servlets where each one re-directs to another. There are way too many servlets for me to enter a mapping between each of these servlet class to a URL-ma...

How do I address unchecked cast warnings?

Eclipse is giving me a warning of the following form: Type safety: Unchecked cast from Object to HashMap<String, String> This is from a call to an API that I have no control over which returns Object: HashMap<String, String> getItems(javax.servlet.http.HttpSession session) { HashMap<String, String> theHash = (HashMap<String, String...

can't run swing from the command line.

i use the command line in windows to compile and then execute my java programs. i've gone to http://java.sun.com/docs/books/tutorial/uiswing/start/compile.html and tried compiling the HelloWorldSwing.java class. it worked, but when i try "java HelloWorldSwing" it gives me a bunch of erros and says something along the lines of Exception i...

How do I change the description of input's displayed for an operation defined using a MXBean

I'm using a MXBean to instrument a certain feature, and I have a method that takes in 3 input arguments. By default, on the jconsole, the arguments are displayed as p1, p2, p3 etc. I have @params describing each parameter. How do I make jConsole use those? public class Sample implements SampleMXBean { /** * method 1 * ...

Java game questions

I am developing a simple multiplayer 2d game of pacman in java for my assignment at university and I want to be able to draw stuff onto this window as well as pick up keyboard input. What would be the best way to do this? Currently for the GUI I have http://pastebin.com/m1009789e Which works fine on the windows machine that I am developi...