java

How do I create executable Java program?

Hi I have programmed a Java Program in JCreator, everything is done, but I want to create an executable file from it, ie I dont want to have to run the program by loading the java classes and compiling then executing, but instead have it as a stand alone executable file. What the quickest way to do this? Thank You ...

Hibernate: "Field 'id' doesn't have a default value"

Hi, all. I'm facing what I think is a simple problem with Hibernate, but can't get over it (Hibernate forums being unreachable certainly doesn't help). I have a simple class I'd like to persist, but keep getting: SEVERE: Field 'id' doesn't have a default value Exception in thread "main" org.hibernate.exception.GenericJDBCException: cou...

JavaEE 5, WAS 6.0 Strange issue with JSP includes

Hi Friends, We are currently in the process of migrating our application from our production environment to a brand new data center. Current Production Environment : Java 1.4, Java EE 3, WAS 5.1, JSF 2.1 New Data Center Environment: Java 1.5, Java EE 5, WAS 6.1, JSF 2.1 Our application is built on JSF 2.1 and contains the code below ...

Spring-MVC controller redirect to "previous" page?

Let's say I've got a form for editing the properties of a Pony, and in my web application there are multiple places where you can choose to edit a Pony. For instance, in a list of Ponies there might be an "edit" link next to each Pony, and when the user is viewing a Pony, there might also be an "edit" link in that view. When a user cli...

Use of Initializers vs Constructors in Java

So I've been brushing up on my Java skills as of late and have found a few bits of functionality that I didn't know about previously. Static and Instance Initializers are two such techniques. My question is when would one use an initializer instead of including the code in a constructor? I've thought of a couple obvious possibilities: ...

Java: Why do two consecutive calls to the same method yield different times for execution ...

Here is a sample code: public class TestIO{ public static void main(String[] str){ TestIO t = new TestIO(); t.fOne(); t.fTwo(); t.fOne(); t.fTwo(); } public void fOne(){ long t1, t2; t1 = System.nanoTime(); int i = 10; int j = 10; int k = j*i; System.out.println(k); ...

Example code for embedding SVG canvas in SWT project?

Is there a good example of how to include an SVG canvas into a Java SWT project (particularly Holongate, though I would be interested in any other options)? Additionally, I would need to support this SVG canvas on Mac OS X, Windows and Linux clients, in case an implementation relies on native libraries. Thanks for any pointers. ...

What is the easiest way to have a custom file implementation that only uses memory in Java

I have a code base that makes extensive use of files to represent a single data object. I have refactored the code so that the data object is now an explicit java object that mostly hides interaction with the underlying file system. However, we use a few external tools (like Weka), that read and write files. Ideally, I would like to...

How do I extend a java class that is instantiated by another class?

Given two java classes, A and B, where A is usually instantiated via B, such as: A myA = B.createA(); Can I create a subclass of A (let's call it SubA) and somehow have it be instantiated by the B.createA() method? (Note that I cannot modify A and B....) I know that not all instances of A are instances of SubA, thus I cannot do ...

Is it possible to read from a Java InputStream with a timeout?

Specifically, the problem is to write a method like this: int maybeRead(InputStream in, long timeout) where the return value is the same as in.read() if data is available within 'timeout' milliseconds, and -2 otherwise. Before the method returns, any spawned threads must exit. To avoid arguments, the subject here java.io.InputStream...

Best Java web architecture book / website?

What is a good book or website that describes the different elements of a Java based web applications architecture? I would like to see a polished treatment of what frameworks are good for the front end, business logic, data storage, and other components. In what contexts they do well in and how well they interact together. ...

eclipse indentation on emacs

I'm an emacs user who just started working for a new company where eclipse is the standard. I've tried eclipse, but I want to also experiment with JDEE (I'm coming back to Java after a long hiatus). The major stumbling block so far is getting the indentation to match. Is there an easy way to do this, or am I going to need to dig deepl...

SSL System Properties - Security Risk???

This is probably a stupid question, but how much of a security risk is it to set my web server ssl configuration (e.g. keystore password) via System.setProperty... If I did something like: System.setProperty("javax.net.keyStorePassword", "password"); Is that likely to cause a security problem? Is there a way to safeguard against t...

Loading up a web.xml for integration tests with jetty

OK this is kind of related to : http://stackoverflow.com/questions/728805/using-jetty-to-install-and-run-servlet-tests-programmatically got great answers there, and have been able to load up servlets programmatically and its all made of awesome. What I would like to do however is load up a web.xml in a test (all in the classpath) and ...

Hide print dialog

Hi, I am printing a Jpanel and its working fine, but now I need the print dialog box, which always appear when the print button is clicked. It suppose to go like, when user press print button the default printer should start printing the job with out coming up with a print dialog box. Here is the code, I am using, Paper paper = new Pape...

GZIP compression did not work good for a data of 64K

Hi I have created compressin and decompression technique using gZipinputstream in both c#.NET and java If I compress upto 15000 bytes in c#.NET then i can decompress it in java but if i compress 64000 bytes in c#.NET then i am not able to decompress it in java. But I can decompress it using C#.NET. So how to come out of this problem Tha...

Load java.util.logging.config.file for default initialization

Hi, I'm trying to load a custom log.properties file when my application is started. My properties file is in the same package as my main class, so i assumed that the -Djava.util.logging.config.file=log.properties command line parameter should get the properties file loaded. But the properties are only loaded when i specify a full abso...

How to prevent multiple dialogs to appear at the same time?

How can I avoid, that a dialog is shown, when there already is one on the screen? Details: In my application many Timers are running. If a fatal error occurs, all the affected threads are going to show a JDialog (by swingx.JXErrorPane.showDialog()), which is not desired. Even if I cancel all the running Timers, still some Dialogs will a...

How can I delete Hudson's built artifacts?

We are using Hudson for our Continuous Integration server and it's great. We have 2 issues with it, which are mildly related. https://hudson.dev.java.net/issues/show_bug.cgi?id=2736 The build order in Hudson means that the downstream dependencies get built a lot more than they need to be. Hopefully this issue will be addressed soon. Si...

Problem with caclulating and displaying floating point numbers in JSP

I'm trying to take two 7 digit numbers (source and target record counts) and calculate the percentage of missing records in the target count. For example, my record counts could be 4084094 for the source, and 4081313 for the target. I'm also using the follow formula to calc the percentage: ((1 - (target / source)) * 100) For my exampl...