java

Converting CSV File to XML in Java

Is there an existing application or library in Java which will allow me to take CSV data and create an XML file? The XML tags would be provided through maybe the first row containing column headings....

How would you access Object properties from within an object method?

What is the "purist" or "correct" way to access an object's properties from within an object method that is not a getter/setter method? I know that from outside of the object you should use a getter/setter, but from within would you just do: Java: String property = this.property; PHP: $property = $this->property; or would you do:...

What is the meaning of the type safety warning in certain Java generics casts?

What is the meaning of the Java warning "Type safety: The cast from Object to List is actually checking against the erased type List"? I get it when I try to cast an Object to a type with generic information, such as in the following code: Object object = getMyList();List<Integer> list = (List<Integer>) object;...

What is the difference between an int and an Integer in Java/C#?

I was just sitting at my local Borders sipping coffee and reading (for free) 'More Joel on Software' when I came across Joel saying something about a particular type of programmer knowing the difference between an int and an Integer in Java/C# (Object Oriented Programming Languages). After a quick 'brain check,' I realized, to my dismay...

Which Build-/Configuration Management Tool?

Which build or configuration management tool are you using in your daily programmer's life? Which would you suggest and why? Are you going for Ant? Do you use Maven? Or is there an alternative out there, like Ivy or Buildr?...

How to get started "writing" a code coverage tool?

Looking for books or other references that discuss actually "how" to write a code coverage tool in Java; some of the various techniques or tricks - source vs. byte code instrumentation. This is for a scripting language that generates java byte code under the hood. ...

Creating a custom button in Java

Is there a way to make a JButton with your own button graphic not just with an image inside the button? If not is another way to create a custom button in java?...

Getting started with a custom JXTA PeerGroup

I have been working with JXTA 2.3 for the last year or so for a peer-to-peer computing platform I am developing. I am migrating to JXTA 2.5 and in the process I am trying to clean up a lot of my use of JXTA. For the most part, I approached JXTA with a "just make it work" attitude. I used it to jumpstart creating and managing my peer-to-p...

What is the best way to parse strings in Java

I have some friends making a text-based game in Java (what the hell?), and they're looking for the best way to parse strings for commands. They've come across many methods and are wondering what would be the best way to go about things....

How do I configure and communicate with a serial port?

I need to send and receive data over serial connections (RS-232 and RS-422). How do I set up and communicate with such a connection? How do I figure out what the configuration settings (e.g. baud rate) should be and how do I set them? In particular I am looking to do this in Java, C/C++, or one of the major Unix shells but I also have...

IllegalArgumentException or NullPointerException for a null parameter?

I have a simple setter method for a Java property and null is not appropriate for this particular property. I have always been torn, in this situation: should I throw an IllegalArgumentException, or a NullPointerException? From the javadocs, both seem appropriate. Is there some kind of understood standard? Or is this just one of thos...

What code analysis tools do you use for your Java projects?

What code analysis tools do you use on your Java projects? I am interested in all kinds static code analysis tools (FindBugs, PMD, and any others) code coverage tools (Cobertura, Emma, and any others) any other instrumentation-based tools anything else, if I'm missing something If applicable, also state what build tools you use and...

How do I use Java to read from a file that is actively being written?

I have an application that writes information to file. This information is used post-execution to determine pass/failure/correctness of the application. I'd like to be able to read the file as it is being written so that I can do these pass/failure/correctness checks in realtime. I assume it is possible to do this, but what are the gotch...

Why can't I call toString() on a Java primitive?

I want to convert a primitive to a string, and I tried: myInt.toString(); This fails with the error: int cannot be dereferenced Now, I get that primitives are not reference types (ie, not an Object) and so cannot have methods. However, Java 5 introduced autoboxing and unboxing (a la C#... which I never liked in C#, but that's besi...

How can I Java webstart multiple, dependent, native libraries?

Example: I have two shared objects (same should apply to .dlls). The first shared object is from a third-party library, we'll call it libA.so. I have wrapped some of this with JNI and created my own library, libB.so. Now libB depends on libA. When webstarting, both libraries are places in some webstart working area. My java code attempt...

Is this really widening vs autoboxing?

I saw this in another question in reference to shortcomings of the java spec: There are more shortcomings and this is a subtle topic. Check this out: public class methodOverloading{ public static void hello(Integer x){ System.out.println("Integer");}public static void hello(long x){ System.out.println("long");}public stati...

Personal Linux web server

I'd like to set up a cheap Linux box as a web server to host a variety of web technologies (PHP & Java EE come to mind, but I'd like to experiment with Ruby or Python in the future as well). I'm fairly versed in setting up Tomcat to run on Linux for serving up Java EE applications, but I'd like to be able to open this server up, even j...

Accessing post variables using Java Servlets

The title says it all. All I really want is the equivalent of PHP's $_POST[], and after searching the web for an hour, I'm still nowhere closer....

Why can't I use a try block around my super() call?

So, in Java, the first line of your constructor HAS to be a call to super... be it implicitly calling super(), or explicitly calling another constructor. What I want to know is, why can't I put a try block around that? My specific case is that I have a mock class for a test. There is no default constructor, but I want one to make the ...

Public/Popular Websites using JavaServer Faces

Are there any popular and/or public websites that utilize the JavaServer Faces framework? I don't ever recall stumbling across any ever on the Internet. In my experience JavaServer Faces is usually reserved for non-public enterprise and business level applications. I am curious to know because I am researching how terrible of an idea it...