java

Hibernate subquery

I have a problem in creating subqueries with Hibernate. Unfortunately the Subqueries class is almost entirely undocumented, so I have absolutely no clue how to convert the following SQL into a Hibernate Criteria: SELECT id FROM car_parts WHERE car_id IN ( SELECT id FROM cars WHERE owner_id = 123 ) I was hoping the following would 'jus...

Has any language been implemented in Java?

Do you know of a runtime written in Java/J2ME, that is capable of reading and executing a script/binary file? ...

Binding Component <-> Container (Enabled property)

Hi everyone, I'm just trying to work out the best way to replicate a pretty useful feature of Windows' Forms.Panel in Java. Basically, when you disable a Windows Forms.Panel, all child control's are set to disabled too. However, their enabled property is preserved such that, when the the Panel is enabled again, any child control that wa...

log4j rootlogger turn off logger for some classes

how can i configure a log4j.properties with a rootlogger = debug, stdout, logfile and org.apache.httpclient = debug which goes into the logfile but not the stdout? raising the rootlogger to info is not acceptable as i have others package at the debug level. ...

In Java, should variables be declared at the top of a function, or as they're needed?

I'm cleaning up Java code for someone who starts their functions by declaring all variables up top, and initializing them to null/0/whatever, as opposed to declaring them as they're needed later on. What are the specific guidelines for this? Are there optimization reasons for one way or the other, or is one way just good practice? Are t...

How to declare a function during program execution?

This is something like Reflection where you can call a method simply by its name, and not a precompiled pointer to it. Like in JavaScript you can: var fun = function(){ alert("Hello World!"); } fun(); Is something like that possible in Java/J2ME? How? ...

How to test for equality of complex object graphs?

Say I have a unit test that wants to compare two complex for objects for equality. The objects contains many other deeply nested objects. All of the objects' classes have correctly defined equals() methods. This isn't difficult: @Test public void objectEquality() { Object o1 = ... Object o2 = ... assertEquals(o1, o2); } ...

Including additional resources with OSGi bundles

I'm working on an OSGi bundle which implements a service as a wrapper around a native executable. That is, the service runs the executable with ProcessBuilder, feeds it some data, and retrieves the result. My question is about the best way to package this bundle. The native executable includes a number of dependent data files which all m...

Java: ObjectOutputStream with Serializable problem

Hello, I have these three classes: Command: package pack; public abstract class Command impements java.io.Serializable { public abstract void execute(); } Client: package pack; // imports.... public class Client { Socket socket; // Constructor... public void sendCommand(Command c) { try { ...

use ${property} in a properties file ?

Hi, look at my "file.properties": key1= My name is key2= ${key1} Martin ! Why when I get the value of "key2" my result is "${key1} Martin !" unlike "My name is Martin !" => I program in Java 6 => I use java.util.Properties ...

Are Hecl scripts as powerful as native J2ME midlets?

Looking over Hecl, the scripting language with a J2ME runtime, I wonder about its capabilities: Assuming my base Midlet has methods and variables that I've written Can the Hecl interpreter run within my Midlet, and side-by-side with my classes? Can the Hecl script call any of my methods within the Midlet? Can the Hecl script utilize a...

Is synchronized static method legal in Java?

Thank you folks. ...

java changing attributes of shapes programatically.

I want to create a number of straight lines connecting small circle shapes. then I want to change the color and width of the lines from within my program. I was thinking of using Canvas to do this but there does not seem to be a way to access individual shapes drawn on canvas to change their attributes after they are drawn. What would be...

Select all data when start editing JTable Cell

Hello! I'm trying for a long time to make a table that works like Excell do. It means, when user starts to insert data into the cells the content into them is selected and changed by the new data inserted. I don't know how to do it, I googled it a lot and didn't give any good idea. All the best! ...

Adding validations to Java Beans via Annotations

I want to add validations to a Java Bean. For example, I want to do the following: @MaxLength(50) @RequiredField public void setEmployeeName(String name){ ..... } I know I can write code that gets the validations for a specific method by calling method.getDeclaredAnnotation after all the bean values have been set. I would like to...

Tool for managing multiple Java web container instances?

I'm looking for a Java Web Container (like jetty and tomcat) or a tool in which I can create/remove server instances through a management console. The problem is that my organization needs to create different instances of a test server for quality control testing (against different database configurations). Currently, I'm having to man...

Hadoop Distribution Differences

Can somebody outline the various differences between the various Hadoop Distributions available: Cloudera - http://www.cloudera.com/hadoop Yahoo - http://developer.yahoo.net/blogs/hadoop/ using the Apache Hadoop distro as a baseline. Is there a good reason to using one of these distributions over the standard Apache Hadoop distro?...

Optimizing Java code

How can I optimize this code ? I made IPFilter and I need to optimize it. package com.ipfilter; import java.util.HashMap; import java.util.Map; /** * IPFilter * * Loads given IP addresses to memory, so you can easily check if ip addres has been blocked */ public class IPFilter { private Map<Integer, IPFilter> ...

Select next cell JTable

Hi, I would like to make a JTable that users when selecting an uneditable cell the it changes the focus to the next editable cell automatically. Important: the user could select a cell by keyboard (tab or arrow) and by mouse clicking. Is it possible?? How to to it? All the Best! ...

Managing concurrent access to an Apache Derby database

Hi, I have an Apache Derby database running (in networked mode) inside a java swing application, I connect to it through direct JDBC calls via a java client application. This is all very good and works great however I know have an additional requirement to implement concurrent licenses for this client/server application. Ideally a user...