java

How do I make a list with checkboxes in Java Swing?

What would be the best way to have a list of items with a checkbox each in Java Swing? I.e. a JList with items that have some text and a checkbox each? ...

Ruby blocks/Java closures in C

I've been trying to understand how Ruby blocks work, and to do that I've been trying to implement them in C (^_^). One easy way to implement closures is to pass a void* to the enclosing stack to the closure/function but Ruby blocks also seem to handle returns and break statements from the scope that uses the block. loop do break i if...

How do you embed binary data in XML?

I have two applications written in Java that communicate with each other using XML messages over the network. I'm using a SAX parser at the receiving end to get the data back out of the messages. One of the requirements is to embed binary data in an XML message, but SAX doesn't like this. Does anyone know how to do this? UPDATE: I g...

RFC calculation in Java need help with algorithm

The RFC for a Java class is set of all methods that can be invoked in response to a message to an object of the class or by some method in the class. RFC = M + R where M = Number of methods in the class. R = Total number of other methods directly invoked from the M. Thinking C is the .class and J is the .java file of which we need to ...

Repository layout for large Maven projects

I have a large application (~50 modules) using a structure similar to the following: Application Communication modules Color communication module SSN communication module etc. communication module Router module Service modules Voting service module Web interface submodule for voting Vote collector submodule for voting etc. for vot...

C# for Java Developer

I'm looking for freely available resources that will help me pick up C# language and some of the basic API (like Collections). I already know Java fairly well, so looking for resources that assume background in Java. ...

Is Project Darkstar Realistic?

Project Darkstar was the topic of the monthly JavaSIG meeting down at the Google offices in NYC last night. For those that don't know (probably everyone), Project Darkstar is a framework for massively multiplayer online games that attempts to take care of all of the "hard stuff." The basic idea is that you write your game server logic ...

Virtual Machine Optimization

I am messing around with a toy interpreter in Java and I was considering trying to write a simple compiler that can generate bytecode for the Java Virtual Machine. Which got me thinking, how much optimization needs to be done by compilers that target virtual machines such as JVM and CLI? Do Just In Time (JIT) compilers do constant foldi...

How do I use 3des encryption/decryption in Java?

Every method I write to encode a string in Java using 3DES can't be decrypted back to the original string. Does anyone have a simple code snippet that can just encode and then decode the string back to the original string? I know I'm making a very silly mistake somewhere in this code. Here's what I've been working with so far: ** note...

How do you convert binary data to Strings and back in Java?

I have binary data in a file that I can read into a byte array and process with no problem. Now I need to send parts of the data over a network connection as elements in an XML document. My problem is that when I convert the data from an array of bytes to a String and back to an array of bytes, the data is getting corrupted. I've test...

Java JPanel redraw issues

I have a Java swing application with a panel that contains three JComboBoxes that do not draw properly. The combox boxes just show up as the down arrow on the right side, but without the label of the currently selected value. The boxes will redraw correctly if the window is resized either bigger or smaller by even one pixel. All of my...

db4o experiences?

I'm currently trying out db4o (the java version) and I pretty much like what I see. But I cannot help wondering how it does perform in a real live (web-)environment. Does anyone have any experiences (good or bad) to share about running db4o? ...

Get application name from Windows XP cut and paste?

This is a bit of a long shot, but if anyone can figure it out, you guys can... In Windows XP, is there any meta-data that comes with a cut and paste action, from which I can ascertain the application that provided the clipboard contents? Bonus question... if there is such information, is there any way I can access it through a Java app...

Do you write exceptions for specific issues or general exceptions?

I have some code that gives a user id to a utility that then send email to that user. emailUtil.sendEmail(userId, "foo"); public void sendEmail(String userId, String message) throws MailException { /* ... logic that could throw a MailException */ } MailException could be thrown for a number of reasons, problems with the email add...

Problems running Swing application with IDEA 8M1

Is anyone else having trouble running Swing applications from IntelliJ IDEA 8 Milestone 1? Even the simplest application of showing an empty JFrame seems to crash the JVM. I don't get a stack trace or anything, it looks like the JVM itself crashes and Windows shows me a pop-up that says the usual "This process is no longer responding" ...

Why can't I declare static methods in an interface?

The topic says the most of it - what is the reason for the fact that static methods can't be declared in an interface? public interface ITest { public static String test(); } The code above gives me the following error (in Eclipse, at least): "Illegal modifier for the interface method ITest.test(); only public & abstract are permi...

Why Java and Python garbage collection methods are different?

Python uses reference count method to handle object life time. So an object has no more used and it will be immediately destroyed. But, in Java, GC(garbage collector) destroys objects which are no more used at specific time. Why Java choose this strategy and what is benefit from this? Is this better than Python approach? ...

Using Regex to generate Strings rather than match them

I am writing a Java utility which helps me to generate loads of data for performance testing. It would be really cool to be able to specify a regex for Strings so that my generator spits out things which match this. Is there something out there already baked which I can use to do this? Or is there a library which gets me most of the w...

How do I convert images between CMYK and RGB in ColdFusion (java)?

I have a need to convert images from CMYK to RGB - not necessarily back again, but hey, if it can be done... With the release of ColdFusion 8, we got the CFImage tag, but it doesn't support this conversion; and nor does Image.cfc, or Alagad's Image Component. However, it should be possible in Java; which we can leverage through CF. For...

What's the best mock framework for Java?

What's the best framework for creating mock objects in Java? Why? What are the pros and cons of each framework? ...