java

How is reference to java object is implemented?

Is pointer is just used for implementing java reference variable or how it is really implemented? Below are the lines from Java language specification 4.3.1 Objects An object is a class instance or an array. The reference values (often just references) are pointers to these objects, and a special null reference, which refers ...

@OneToMany association joining on the wrong field

I have 2 tables, devices which contains a list of devices and dev_tags, which contains a list of asset tags for these devices. The tables join on dev_serial_num, which is the primary key of neither table. The devices are unique on their ip_address field and they have a primary key identified by dev_id. The devices "age out" after 2 we...

Multiplication...........

I've coded a .... I believe my approach is right, but I'm not 100% sure. In respect to the threads, I don't understand why I can't just run a (new MatrixThread(...)).start() instead of using an ExecutorService. Additionally, when I benchmark the ...approach versus the classical approach, the classical is much faster... What am I doing ...

Java GUI: Sharing values across different JFrames

I'm writing some experimental GUI code. I'm trying to set it up so calling main generates two windows, each with a button and a label. The label displays how many times the button has been clicked. However, I want it so if you click the button in one window, the label in the other updates. How would I do this? import javax.swing.*; impo...

Best mail library for java web applications

I am investigating on the best free mail library to use for java web applications. It is something with more support and easy to use. If it's complex but would be justified by its great features it might do. Have any suggestions? ...

convert java awt applet to flash / flex

what's the shortest path to convert a java applet to flash / flex ? have you any experiences with something similar? please describe. thanks guys ...

Specifying a custom media size with java printing

I need to specify a custom media for printing on a 32x48 sheet of plotter paper without using a page setup dialog. The MediaName class hints at creating a custom MediaName subclass, but there's no way to specify a custom media size with this MediaName. How does one print to custom-sized media from within Java? I am using the java 1.3+ ...

Ivy failed to resolve dependency : What to check, what to do ?

Hi everyone, I'm using Ivy to resolve dependency in my very small project. It's the first time I'm doing that and it's more to learn as my project is very small. I had a problem 5 minutes ago, when trying to download log4j. My configuration is very basic, I have an ant task : <target name="resolve" description="--> retrieve dependenc...

Is it bad practice to use an Enum's ordinal value to index an array in Java?

I have two arrays: Walls and Neighbors. public boolean[] walls = new boolean[4]; public Cell[] neighbors = new Cell[4]; and I have an Enum: enum Dir { North, South, East, West } Now, I would like to be able to access walls or neighbors by their direction, so I don't have to pass around a bunch of magic indexes. How...

Drools Debug listeners pointless as events don't have toString()?

I'm new to Drools and they have these very nice debug listeners, DebugAgendaEventListener and DebugWorkingMEmoryEventListener, that spit events out to System.err. That's all well and good, but the underlying events don't implement toString() so you end up with a debug line that looks like: org.drools.event.rule.impl.ActivationCreatedEve...

How to check in Java App Engine if we are on development workstation

Hello there, I'd like to do this in Java Google App Engine if(developmentMode) foo(); else bar(); Does anyone know a good way to do this? Daniel ...

JSP, JavaScript, and Java Objects

I'm new to JSPs so bare with me. I have a JSP where I'm using a javascript framework to build a chart using the Google Visualization API. My servlet is returning a sales hashmap object with year as the key and integer (sales number) as the value. My javascript uses the sales object to add data to the Google chart API which builds my ch...

Connecting an input stream to an outputstream

I saw some similar, but not-quite-what-i-need threads. I have a server, which will basically take input from a client, client A, and forward it, byte for byte, to another client, client B. I'd like to connect my inputstream of client A with my output stream of client B. Is that possible? What are ways to do that? Also, these clients...

On static and non-static initializing blocks in Java

I originally thought that static blocks were for static variables but the compiler allows both A and B to compile and run, what gives? A private static final Map<String,String> m = new HashMap<String,String>(); { m.put("why", "does"); m.put("this","work"); } B private static final Map<Stri...

Java Web Start: How to write files to windows UNC Path?

I have an Java application for copying large amounts of data from users' workstations to a server. The java.io.File class is supposed to work with UNC paths very well and in fact it does but only when I run the app in standard execution model. When the application is launched via Web Start I get a FileNotFoundException when trying to op...

Java: clone() and equality checks

Perhaps I don't understand how clone() works. Shouldn't the return value equal the caller? int[] nums = new int[] {0, 1, 2}; int[] list = nums.clone(); nums.equals(list); //returns false. Why? for (int ket = 0; ket < list.length; ket++) { System.out.println(list[ket] == nums[ket]); //prints out true every time } list == nums /...

Calling a Java class from Adobe Air app

I have to develope a simple desktop application. I have to call my Jar behind it. I am thinking that I should have Adobe Air interface that will call my Jar. Is it possible in Air. If yes, then I am going to learn Adobe Air, otherwise I will develope it in Swing. Thanks. ...

Is there a way to read the jvmRoute value from the JBoss server.xml at runtime?

Our JBoss server.xml file has this line: <Engine name="jboss.web" defaultHost="localhost" jvmRoute="app_server_01"> Is there any way to get the jvmroute value (in this case app_server_01) at runtime using Java? Background We've got session affinity (sticky sessions) configured between our app servers and Apache servers. JBoss appe...

Fastest most efficient way to determine decimal value is integer in Java

Given a double variable named sizeValue and sizeValue contains something other than 0, what is the most efficient way to determine that sizeValue contains a value that is an integer? Currently i'm using sizeValue % 1 == 0 any other faster ways? ...

GA written in Java

I am attempting to write a Genetic Algorithm based on techniques I had picked up from the book "AI Techniques for Game Programmers" that uses a binary encoding and fitness proportionate selection (also known as roulette wheel selection) on the genes of the population that are randomly generated within the program in a two-dimensional arr...