java

What's Alternative to Singleton

We have a class that holds configuration information for the application. It used to be a singleton. After some architectural review, we were told to remove the singleton. We did see some benefits of not using singleton in the unit testing because we can test different configurations all at once. Without singleton, we have to pass the i...

Persistent connections between Flash client and Java server

I'm new to Flash. I'm planning to create a game client in Flash (running in browser) that needs to talk to a server written in Java. Connection between client and server needs to be persistent. I'm aware of XMLSocket - is that the only way to go? Any recommendations? Thanks! ...

Accessing a Java generics stored in a Map

Hello I'm trying to access a custom Java generic stored in a map as below. Unfortunately I get a type mis-match error. Now, I can cast it to the type I want because but this seems messy to me. Is there a clean way of doing the assignment? Thanks public interface BusinessObject { } public class SalesItemA implements BusinessObject { }...

Is there a new library for Java that supports IPv6 on Solaris?

I'm doing the following to lookup an Internet address. It fails specifically on Solaris machines that have IPv6 nameservers in the resolv.conf. Works fine on Windows machines that have IPv6 nameservers and on IPv4 only Solaris machines. From the error returned it appears that the Java "getAttributes" line is failing internally (somewh...

Prevent Encryption (Krypto) Of Url Paramaters in IBM Commerce Server 6

Hi we are using IBM Commerce Sever Moving from one view to another using via code like below. protected void prepareResponse(){ ... String returnUrl = "www.example.com/aNewPage.jsp?aUrlParameter=123&anotherParameter=654" ... StringBuffer sb = new StringBuffer(returnUrl); sb.append("&storeId=").append(commandContext.getStoreId()); sb.app...

java generics design problem (state machine)

i made a state machine and would like it to take advantage of generics in java. currently i dont see the way i can make this work and get pretty looking code. im sure this design problem has been approached many times before, and im looking for some input. heres a rough outline. class State { ... } only one copy of each distinct st...

Java: Hibernate - Query to delete from multiple tables.

Hi, i have two tables connected by a foreign key with a one to many relation. in entity A i have the following : @org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) @OneToMany(mappedBy="monitoredFlight", fetch = FetchType.LAZY) @OnDelete(action=OnDele...

What is the equivalent of a Java applet in .NET?

What is the equivalent of a Java applet in .NET? Is it Silverlight? Is Java applet still widely in use? ...

Is having Eclipse OSGI Activators inheriting from each other a good idea?

If you have a common eclipse/osgi code platform on which you build various products can you/should you inherit activators from the common code E.g. org.test.common.PluginActivator org.test.common.ui.UIPluginActivator org.test.product1.Product1PluginActivator org.test.product1.ui.Product1UIPluginActivator org.test.product2.Product2Plu...

how Java classloaders work for "regular" circumstances (nonexplicit use of classloaders)

I'm looking into dynamic modification of classpath. I found one solution that works nicely but it does so using an explicit call to addURL(). (presumably at startup) However, I would like to intercept the class-loading process at runtime to locate classes if the default classloader can't seem to find them. I tried to subclass ClassLoade...

Can I create self-signed certificate in Java which will be automatically trusted by web browsers?

Hi, I've generated a self-signed certificate for my Java app using keytool. However, when I go to the site in a browser it always pops up with a warning - saying this site does not own the certificate - is there a way to self-sign/doctor a certificate so I won't get these warnings in a browser? Both server and browser are located on t...

why is 24 * 60 * 60 * 1000 * 1000 divided by 24 * 60 * 60 * 1000 not equal to 1000 in Java?

why is 24 * 60 * 60 * 1000 * 1000 divided by 24 * 60 * 60 * 1000 not equal to 1000 in Java? ...

Reading properties file from JAR directory

I’m creating an executable JAR that will read in a set of properties at runtime from a file. The directory structure will be something like: /some/dirs/executable.jar /some/dirs/executable.properties Is there a way of setting the property loader class in the executable.jar file to load the properties from the directory that the jar is...

JPA using multiple database schemas

I'm having a bit of trouble with one particular issue using JPA/Spring: How can I dynamically assign a schema to an entity? We have TABLE1 that belongs to schema AD and TABLE2 that is under BD. @Entity @Table(name = "TABLE1", schema="S1D") ... @Entity @Table(name = "TABLE2", schema="S2D") ... The schemas may not be hardcoded in an ...

Is there a problem with a4j:commandButtons that get 'reRendered'?

The code below has been simplified to the simplest possible thing that is failing. Basically when someone requests to confirm an action, I am forcing them to login, then allowing them to confirm the action. This is all done with ajax. The first form submission happens correctly but the second one fails to run the desired ActionListener. ...

java.io.FileNotFoundException: (Permission denied)

i am tying to read a file placed in my documents folder on vista. The fiel does exists on a specified location but still i am getting the following error when trying to open an input stream to the file java.io.FileNotFoundException: (Permission denied) at java.io.FileInputStream.open(Native Method) at java.io.FileInpu...

Programatically closing currently displayed Java Swing JDialog box

Hi there I am working on an Java Swing application that performs a search on a database. It has 2 JDialog boxes that popup during the search. The first tells the user that the search has started and has an OK button to close. The second tells the user that the search has returned and is also closed by hitting the OK button. I there a w...

Java Vector or ArrayList for Primitives

Is there an expandable array class in the Java API equivalent to the Vector or ArrayList class that can be used with primitives (int, char, double, etc)? I need a quick, expandable array for integers and it seems wasteful to have to wrap them in the Integer class in order to use them with Vector or ArrayList. My google-fu is failing ...

Easiest way to unpack a jar in java

Basically, I have a jar file that i want to unzip to a specific folder from a junit test. What is the easiest way to do this? I am willing to use a free third party library if it's necessary. ...

Java Queue implementations, which one ?

From javadoc: A ConcurrentLinkedQueue is an appropriate choice when many threads will share access to a common collection. This queue does not permit null elements. ArrayBlockingQueue is a classic "bounded buffer", in which a fixed-sized array holds elements inserted by producers and extracted by consumers. This class supports an optio...