java

Cant run my programme from command line

I have a main method that creates an instance of a logic class public static void main(String[] args) { try { Logic logic = new Logic(args[0]); ....... do some stuff here } catch (Exception e) { System.out.println("Error Encountered Details: " + e); } } the thing is th...

how to map a one-to-many collection to a joined subclass when key is in the parent class

I'd like to map a one to many collection to a subclass but the key of the collection is an attribute of the parent class. Currently i'm mapping AbstractFoo Foo and Bar class like this : <class name="AbstractFoo" abstract="true" table="abstractFoo"> <id name="_id" column="foo_pk"> <generator class="native" /> </id> <many-to-on...

JUnit Test Compiling

Hello, I would like to compile JUnit from windows command line. I have a project that contains many different packages. I can compile and run this project from the command line. However, I have difficulties to compile JUnit class that I have created. My JUnit class imports only my model and uses the methods to ensure that my model is c...

ByteArrayOutputStream uploaded to server

I am working on an applet that interfaces with a signature pad. The signature pad API has a function that returns a BufferedImage (assume its called API_CALL_TO_RETURN_BUFFERED_IMAGE()). I can encode to jpeg and write this image to file just fine (Using FileOutputStream). However, instead of writing to the local disk, I need to upload...

Is there a Java-applet implementation of HTML5 WebSockets?

Is there a Java-applet implementation of HTML5 WebSockets? I'd like to use WebSockets for a new project, and provide a backward compatible implementation of WebSockets (for all current non-dev browsers) using Java (or maybe Flash). I only want to write and maintain WebSockets on the server-side. I only want to have to deal with the We...

How can I dynamically look up a static class member in Clojure?

In Clojure I can look up a static member of a Java class (e.g. a field holding a constant) like this: ClassName/CONSTANT_FIELD How can I access the member when I only know it's name at runtime? An example would be looping over a sequence of field names and getting all the field values. I would like to do something like this (this cod...

Using a JNDI datasource created by another application with Tomcat

Hello, I have a .properties file in my application which contains dataSource properties. I set up a JNDI reference to this dataSource using the following code : // first I create MyDataSource from the properties found in the .properties file //then : Context initContext = new InitialContext(); initContext.createSubcontext("jdbc"); ini...

casting byte[] to user defined class in java

i want to cast byte[] which i got from socket a class which I write it (Message). I tried byte[] data=new btyte[100]; . . . Message m=(Message)data; but it did not work and give me error what should I do? ...

Is there something like CodeRush from Java?

Is there something like CodeRush for Java? ...

Java Swing GUI hour glass

In my Swing program there is a JTabbedPane, when user clicks on a tab, the program takes a while to get the data and process the results, then shows the results in the selected tab, how can I display a hour glass, or something of that effect so that user knows it's processing data, not to click on the tab again before it finishes it job....

How do you name a SwingWorker thread? Open to code or best practices

I'm trying to debug a horrible exception that is occurring in a SwingWorker thread. If I could name my SwingWorker threads, then I could better interpret the stack traces I am receiving. It doesn't seem possible to name a SwingWorker thread (is it?). I'm looking for any best practices or 'tricks' to help me properly identify my worker t...

Compiler to translate Java bytecode to platform-independent C code before runtime?

I'm looking for a compiler to translate Java bytecode to platform-independent C code before runtime (Ahead-of-Time compilation). I should then be able to use a standard C compiler to compile the C code into an executable for the target platform. I understand this approach is suitable only for certain Java applications that are modified...

Convert XML document from Latin1 to UTF8 using Java

I am trying to create an XML document (rss feed) and have worked out all the kinks in it except for one character encoding issue. The problem is that I am using a UTF-8 encoding like so <?xml version="1.0" encoding="UTF-8"?> except the document itself is not encoded to UTF-8. I am using the org.apache.ecs.xml package to create all the ...

Java - to i++ or ++i and whats the difference

Possible Duplicates: What is the difference between i++ and ++i in Java? Is there a difference between x++ and ++x in java? All in the question really, have seen many people say oh; why am i doing i++, dont i no ++i is quicker etc, but its just how i was taught can anyone provide me with a reason why one is better than the ot...

HornetQ OutOfMemory on startup with big journal

Using: HornetQ 2.0.0.CR2 Default configurations for the stand-alone/non-clustered server. When I try to startup the server with a big journal (> 1Gb), I got a OutOfMemory exception: [main] 12:59:43,505 INFO [org.hornetq.integration.bootstrap.HornetQBootstrapServer] Starting HornetQ Server [main] 12:59:44,526 INFO [org.hornetq.core.ser...

Java: RMI vs Web Services

Hi, I need to create a distributed application consisting of multiple clients that send files (plus info about files) to one server, also query that server. Clients must access to that Web Server from inside the company for sending the files. But, occasionally some specific queries must run outside the company. I think, given what I k...

How can I make my Java application with audio play nice in Linux?

I have a Java application whose UI relies heavily on audio. On Windows and OS X, everything works fine; on Linux, however, the application requires exclusive access to the sound device, a LineUnavailableException is thrown and no sound is heard. I'm using Kubuntu 9.10. This means that no other application can play audio while the progra...

Circularity in Class intialization

I was reading something today and came across a statement that said: Lazy instantiation helps avoid harmful circularity in class intialization. What does circularity in Class Instantiation mean? ...

If all collection attributes are thread-safe , can we say that this collection is thread-safe ?

If all attributes (or items fields, or data members) of a java collection are thread-safe (CopyOnWriteArraySet,ConcurrentHashMap, BlockingQueue, ...), can we say that this collection is thread-safe ? an exemple : public class AmIThreadSafe { private CopyOnWriteArraySet thradeSafeAttribute; public void add(Object o) { ...

How does Java 16 bit chars support Unicode ?

Javas char is 16 bit, yet Unicode have far more characters - how does Java deal with that ? ...