java

How to do custom-query based collection mappings in Hibernate?

I have an object that is mapped to have a set of objects, very simple. However, what I really want to do is put some criteria on that mapping. Here's the current mapping: <set name="ops" inverse="true" cascade="all, delete-orphan"> <key column="cityblock_id" on-delete="cascade"/> <one-to-many class="com.tamedtornado....

A programmer trying to understand CANopen

This is continuation of the series of questions I have posted last week at http://stackoverflow.com/questions/423526/java-and-canopen. Thank you, Matli, for having answered all my questions. Current Situation I have to write a Java program to interpret CANopen messages. Due do certain circumstances, I am unable to get my hands on the ...

Spring-ws or Axis2 or Something else for "Contract-First" approach to WS

Everyone's saying "Contract-First" approach to design WS is more inclined to SOA style design. Now, if we take the available open-source frameworks available to achieve that we have Spring-ws and also Axis2(which supports both styles). I have a task to design SOA based e-commerce app. where loose coupling, quick response, security and sc...

What single Java book would you recommend for an experienced software developer?

Assuming an experienced software developer fluent in many languages, but having not entered the Java world from the ground floor, which single book related to the huge space that is the Java world would you recommend as a decent overview from which further expertise can be developed? ...

Java: How do you style Swing components?

Hello, I'm writing my first Java project. I was wondering if it's possible to style the Swing components (set a background color, remove the borders from the buttons, etc.) ...

Servlet/JSP URLs when forwarding requests

My web app has a servlet called admin which when navigated to checks if the user is logged in and if the are directs to the the admin section, but if they aren't it directs them to a JSP page with a sign-in form. The name of the JSP doesn't appear in the URL, it stays as /admin. But then when the JSP posts to another servlet to validat...

Automatic .toString() when calling a method?

Hello, I got the code of a former employee. There are many calls to methods like: foo(val,...); where void foo(String s,...) { ... } and val is an int. Of course, I get an error. As a workaround I pass ""+val to foo. I wonder if there is a better way. ...

What is the best mechanism for testing applets?

I'm trying to effectively build a functional test suite for an applet, and I'm trying to find a good framework for it. In the past, when I wanted to design a test suite that would serve as both functional and load testing on an application, it has always been a web-based application, or at least some kind of service-based application, a...

Recommendations of a high volume log event viewer in a Java enviroment

I am in a situation where I would like to accept a LOT of log events controlled by me - notably the logging agent I am preparing for slf4j - and then analyze them interactively. I am not as such interested in a facility that presents formatted log files, but one that can accept log events as objects and allow me to sort and display on e...

How to get a more compact automatic indentation in Eclipse (for Java)?

What is the code formating option to indent as: Log.w(TAG, String.format( "Upgrading database from version %s to %s which will destroy all old data", oldVersion, newVersion)); instead of as: Log .w( TAG, String .format( "Upgrading database from version %s to %s which will destroy all old data", oldVersio...

How to get the max sizes of the heap and permgen from the JVM?

I am trying to find out programatically the max permgen and max heap size with which a the JVM for my program has been invoked, not what is currently available to them. Is there a way to do that? I am familiar with the methods in Java Runtime object, but its not clear what they really deliver. Alternatively, is there a way to ask Ecl...

Converting Oracle Forms 10 to Java

There are a number of commercial products available: Exodus Evo Also Oracle Application Express (APEX) is releasing a Forms Converter in Oracle Application Express 3.2 (which is now in beta). Has anyone used any of these tools? How much of the process do they automate? What’s the quality of the converted code? Are they worth the co...

What are some common Java pitfalls/gotchas for C++ programmer?

As the question says, what are some common/major issues that C++ programmers face when switching to Java? I am looking for some broad topic names or examples and day to day adjustments that engineers had to make. I can then go and do an in-depth reading on this. I am specifically interested in opinions of engineers who have worked in C...

Python: JFileChooser for Python?

I was wondering if there is something similar to Java's JFileChooser for Python? JFileChooser is a graphical front end to choose a file. Preferably something that is already with Python..maybe with Tkinter. Thanks for your help :) ...

java decimal String format

I need to format a decimal value to a string where i always display at lease 2 decimals and at most 4. so for example "34.49596" would be "34.4959" "49.3" would be "49.30" can this be done using the String.format command? Or is there an easier/better way to do this in java. ...

Too Little CPU Utilization in Java

Hey stackoverflow community! I'm having an issue where a highly involved algorithmic program is using TOO LITTLE cpu utilization: somewhere between 3 and 4%. It is taking very long to return results, and I believe it's just not working hard enough. Do any of you geniuses have any ideas why this would occur - if anything I would expect...

Class inheritance with Hibernate and hbm2java

I am generating my domain objects from my hbm files with hbm2java and now I want them to all inherit a base class. This class will have some utility methods for dealing with listeners. It does not really need to be persisted and I am hoping that I would not have to do a hbm file for it since it will be abstract and only have methods. Is ...

Monotonically increasing time in Java?

In a Java application I want to be able to take a timestamp at the start of an operation and be able to periodically check how long the operation has been running. The catch is: I do not want to be impacted by the Network Time Protocol moving the clock around, or the admin changing the time, or anything which can abruptly adjust the time...

Simple SWT question, how to have text fields fill 100% horizontally

If I have a text field with SWT, how can I get the field to fill to 100% or some specified width. For example, this text field will only reach for so much horizontally. public class Tmp { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); GridLayout gridLay...

Working with Eclipse, writing servlets in java...

Another day, another class... I have gotten everything working for my class in which I am using Tomcat and Eclipse to write java servlets. What I would like to know is why eclipse seems to give me problems when I try to edit the servlet-name in the web.xml file. Does eclipse not allow you to edit this file? I know that it automaticall...