java

Eclipse plugin that generates convenience methods around collections

Sample case: class Test { final Set<String> uniqueNames = new HashSet<String>(); } But w/ the help of a plugin can generate methods like this (similar to Generate getters/setters) class Test { final Set<String> uniqueNames = new HashSet<String>(); public boolean add(String name) { return uniqueNames.add(name); }...

How to measure the response time between a server and a client that communicate using the UDP protocol ?

The aim of the test is to check the shape of the network response time between two hosts (client and server). Network response = the round trip time it takes to send a packet of data and receive it back. I am using the UDP protocol. How could I compute the response time ? I could just subtract TimeOfClientRequest - TimeOfClientResponseRe...

How to check if the key pressed was an arrow key in Java KeyListener?

Can you help me refactor this code: public void keyPressed(KeyEvent e) { if (e.getKeyCode()==39) { //Right arrow key code } else if (e.getKeyCode()==37) { //Left arrow key code } repaint(); } Please mention how to check for up/down arrow keys as well.Thanks! ...

virtual listbox in Swing

I'm trying to figure out how to make a virtual listbox (or tree or outline) in Swing -- this would be one where the listbox can show a "view" within a large result set from a database without getting the entire result set's contents; all it needs to give me is a heads up that Items N1 - N2 are going to need to be displayed soon, so I can...

Is there a Java package to read the UNIX /etc/group file?

I have been scouring the Internet looking for a Java package/class that will allow me to parse the UNIX /etc/group file. While it really wouldn't be so hard to write this from scratch, I'm quite surprised not to find something already out there. There is a POSIX passwd class (see http://www.bmsi.com/java/posix/docs/posix.Passwd.html), ...

Create a temporary directory in Java

Is there a standard and reliable way of creating a temporary directory inside a Java application? There's an entry in Sun's issue database, which has a bit of code in the comments, but I wonder if there is a standard solution to be found in one of the usual libraries (Apache Commons etc.) ...

"cannot find symbol method getGL()" (and now getGLU() as well)

I'm trying to learn how to use JoGL, and for some reason I'm getting this error despite having all of these imported: import javax.media.opengl.*; import javax.media.opengl.glu.*; import com.sun.opengl.util.*; import com.sun.opengl.util.j2d.*; public void display(javax.media.opengl.GLDrawable gLDrawable) { final GL gl = gL...

Java lib to compress html file?

Does anyone know any good java library (or single method) that can strip extra spaces (line breaks, tabs, etc) from an html file? So html file gets turned into 1 line basically. Thanks. UPDATE: Looks like there is no library that does that so I created my own open source project for solving this task: http://code.google.com/p/htmlcompr...

Is Future.get() a replacement for Thread.join() ?

I want to write a command line daemon that runs forever. I understand that if I want the JVM to be able to shutdown gracefully in linux, one needs to wrap the bootstrap via some C code. I think I'll be ok with a shutdown hook for now. On to my questions: My main(String[]) block will fire off a separate Superdaemon. The Superdaemon wil...

Does Weblogic 9.2 support Sun Jdk 1.6?

Does anyone have experience running Weblogic 9.2 on JDK 1.6? I am having trouble finding that information on Oracle site. In the Supported Configurations page they just mention Sun 32/64bit JDK but I haven't found any references to specific java version. I would like to upgrade from java 1.5 to 1.6, but we are not quite ready yet to upg...

How to output cache files and do custom logging - jboss/java project

I am a .Net developer who is starting to do more and more Java development at work. I have a specific question about caching that I hope you guys can solve or offer suggestions. We are starting a java project that will be deployed on a Linux box running JBoss. We are planning ahead and try to think about our caching strategy. One thi...

How to designate resources as do-not-translate?

I work on the localization of Java software, and my projects have both .properties files and XML resources. We currently use comments to instruct translators to not translate certain strings, but the problem with comments is that they are not machine-readable. The only solution I can think of is to prefix each do-not-translate key with ...

Running SWT components within a Swing App

I was wondering if anybody had any experience trying to run a complex SWT UI hosted inside a Swing component. I've managed to get a very simple demo going but if anyone else has tried and failed / succeeded to do this it'd be great to learn from their experiences. So to reiterate my application is a Swing app I wish to make use of a co...

Updating a database while using a preparedStatement select

Hi I'm selecting a subset of data from a MSSql datbase, using a PreparedStatement. While iterating through the resultset, I also want to update the rows, at the moment I use something like this: prepStatement = con.prepareStatement( selectQuery, ResultSet.TYPE_FORWARD_ONLY, Resu...

Can I develop an iPhone app using java?

Hi Is it possible to develop applications for the iPhone using Java? And if so, does it allow the use of custom jar files? Thanks. ...

Are certifications useful for Java programmers who wish to advance their career?

I have just started my career as a programmer. If I do Java certification starting from Sun Certified Java Programmer level (foundation level) and then web component developer and business component developer on speciality level, will it be useful for off campus placement and for growth in company? ...

Case Insensitive Ternary Search Tree

I had been using Ternary Search Tree for a while, as the data structure to implement a auto complete drop down combo box. Which means, when user type "fo", the drop down combo box will display foo food football The problem is, my current used of Ternary Search Tree is case sensitive. My implementation is as follow. It had been used by ...

Difference between Enumeration<? extends ZipEntry> and Enumeration<ZipEntry>?

Is there a difference between Enumeration<? extends ZipEntry> and Enumeration<ZipEntry>? If so, what is the difference? ...

Is it possible to transform javabeans with XSLT and JXPath?

Suppose I have a vanilla javabean: class Person { String firstName; String lastName; ... } Now suppose I want to transform this into another javabean: class Human { String name; ... } I'm currently using JXPath to help me transform one to the other: JXPathContext personContext = JXPathContext.newContext(person); JXPathCo...

Is overloading really the only way to get default values for method parameters in Java?

I'm quite new to Java and from Python and PHP, I'm used to default values for function parameters. So I have a habit of writing methods that are designed to be called from slightly different situations where you want to set only some of the values. For example, in my PHP code, this would be common where I have factory methods that provi...