java

JFileChooser for directories on the Mac: how to make it not suck?

The JFileChooser in "directories only" mode on the Mac has two serious, crippling problems: 1) You cannot create directories with it 2) You cannot switch drives This is rather a huge problem for my installer app. As far as I can tell, Apple provides no way around this problem, you can't even activate the non-native directory chooser ....

Sychronizing on an interned String

usecase example I have a servlet that is receiving login requests. If a login is currently in process OR the user is already logged in, the servlet should abort and inform the caller. current design Taking inspiration from database sharding, I plan to use the first character of each userid as a synchronization key. void login( Stri...

Matisse or Jigloo ?

We have a dilema; developing desktop application using matisse or jigloo.. Matisse has this XML form files which we are affraid of maintaining later, we don't even know should MyEclipse further support Matisse, even Netbeans - do you think they will give up os support of Matisse? Moreless Jigloo and Matisse have similar behaviour, alt...

Spring: JUnit-Test: applicationContext is not loaded...

Hi all, I've got the following Test-class, but it doesn't matter what I set as "ContextConfiguration-locations" - it never set my UserService. And it doesn't throw any error when I set a non-existing file in the locations-property... what am I doing wrong? @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "cla...

Java List parameterized?

Hi, I am quite new to Java ... I wrote a class called DLPFile which is basically a container of other objects like Strings, ints, floats, etc. When putting my files into a List and then saving it in my session (which is from Map class) variable is easy; DLPFile file = new DLPFile(); List <DLPFile >fileList = new ArrayList <DLPFile>...

Generic tree implementation in Java

Is anyone aware of a generic tree (nodes may have multiple children) implementation for Java? It should come from a well trusted source and must be fully tested. It just doesn't seem right implementing it myself. Almost reminds me of my university years when we were supposed to write all our collections ourselves. EDIT: Found this pro...

Java library for database backed collections

I am looking for an efficient sql backed collections library, for the Java programming language. I need to do database manipulations that fit very well the Collections API, is there something that can be a good bridge for that, or must I roll my own thing. ...

Running a java process with remote management enabled

I am trying to run a java process and enable remote connections using jconsole. I add the following parameters to the command line (before the main class): -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote. authenticate=false using netstat, I see that the jvm is listening on port 9999: tcp6 0 0 :::999...

Arrays.binarySearch doesnt work like it should

I have string array [1, 2, 3] and i search for all of those numbers using Arrays.binarySearch, it find 1 and 2, but with 3 it returns -1. any idea why it works that way? what is better alternative to always working search in array/collection? ...

Hibernate not saving collection of values

Okay, I've used Hibernate in several projects now but I did not learn its intricacies before using it. I started with looking at codes that used JPA Annotations and integrated with Spring and everything worked well. But now that I want to teach basic Hibernate to my students and I'm in the process of creating an example and using the doc...

Copy STDOUT to file without stopping it showing onscreen

The program I am making is designed to be run unattended, because of this I have redirected the stdout and stderr streams to a log file. While this works without any problems, while I am still making and debugging the software I would like it to show on the screen as well. Is this possible? To redirect the streams I have used System.se...

Core dump for process spawned from Java

Hi, My Java (Eclipse) application is spawning a child process, monitoring its stdout stream and exit value. When the child process is crashing with SIGABRT, there is no core dump file created. If I start the child process manually and kill it, the core dump is there alright. I couldn't find any info about whether the JVM prepares someh...

reference problem when reaching ResourceMap's String?

I have been developing desktop application in Java. Here, it shows how i reach string of Properties file. Key-value of String is HDI.Device.1.ID org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(HDIManagementApp.class).getContext().getResourceMap(HDIManagementView.class);String ID=resour...

best resources to start programming eclipse plug-ins

Either books (free or not), online tutorials, articles, etc. ...

java: how many times is the collection expression evaluated in a "foreach"

if I do this in Java: for(String s : myCollection.expensiveListGeneration()) { doSomething(); } is expensiveListGeneration() invoked just once at the beggining or in every cycle iteration? Is it implementation dependent? ...

How can I change the text that is actually displayed by a JTextArea?

Hi. Does anyone know if there is a JTextArea method that I can override to change what is displayed on screen? I want to keep the contents of the field the same. Ie. If I set the text to "hello" and I call getText(), I wan't it to return "hello". However, I wan't to be able to override what is displayed on screen (Eg. to replace with '...

Java override explanation

Here is my code class Glyph { void draw() { System.out.println("Glyph.draw()"); } Glyph(int i) { System.out.println("Glyph() before draw()"); draw(); System.out.println("Glyph() after draw()"); } } class RoundGlyph extends Glyph { private int radius = 1; RoundGlyph(int r) { super(r); radius =...

Binding an IPv6 server socket on Windows

I try to bind an IPv6 server socket in Java 1.6 on Windows 7, using this fragment: ssock = ServerSocketChannel.open(); ServerSocket sock = ssock.socket(); sock.bind(new InetSocketAddress(InetAddress.getByAddress(new byte[16]), 0)); Unfortunately, this fails with an IOException: Address family not supported by protocol family: bind I...

Is there a Java library that performs a message digest on a tree of objects?

I am looking for a library that, given a tree of objects, performs a message digest or hashing on the entire structure. I want to see if an object passed to a method gets modified or not (this object contains other objects, who contain objects and so on – none are immutable). Is there a way to check if the state of any object in the ...

Bundling the JRE with a Java application

Hi, I have created an exe with a launch4j Ant script and build.xml file. I want to bundle the JRE in my application and have to distribute it to clients. How do I do this? Thanks, Rajani ...