java

Generics erasure and legacy code

In many books is said that the reason for which Java's generic use erasure is to have compatibility with legacy code. Ok, very good but can anyone show me some simple examples where some generic code interact with old legacy code and vice-versa? ...

Struts 1 MessageRessources - argument

Is it possible to do something like this: <bean:message bundle="MyBundle" key="mytext.text" arg0='<input type="text" name="text" value="<%=num %>"'/> I know that it is possible to pass an HTML element, but I will end up with an input box with the value "<%=num%>" instead the actual value of that variable. What am I missing? ...

Unable to inspect variables on eclipse

I'm unable to inspect variables on eclipse when debugging remote Java application. What could be the reason. EDITED: I'm not able to inspect any variables. Message shown in inspector mini window is 'variable name cannot be resolved'. I'm able to see the contents when I run it locally with test code. ...

Ant + JUnit: NoClassDefFoundError

Ok, I'm frustrated! I've hunted around for a good number of hours and am still stumped. Environment: WinXP, Eclipse Galileo 3.5 (straight install - no extra plugins). So, I have a simple JUnit test. It runs fine from it's internal Eclipse JUnit run configuration. This class has no dependencies on anything. To narrow this problem do...

How to change only the protocol part of a java.net.URL object?

I have a java.net.URL object that uses the HTTPS protocol, e.g.: https://www.bla.com And I have to change only the protocol part of this URL object so that when I call it's toString() method I get this: http://www.bla.com What is the best way to do that? ...

Why doesn't GCJ find the classes from my imported packages?

I want to compile a small Java application to a Windows executable. The application is very small, only a single main class, but it uses Apache POI. When I compile it, everything works fine, as long as I put the POI Jar into the class path argument. But when it comes to linking, GCJ cannot resolve the references the classes in the POI...

How do I print the class structures in a jar file using the javap tool?

I want to list the methods of the class files in the jar using the javap tool. How do I do it so that it lists the methods and members of all the class files in the jar. Right now I am able to do it for just one class at a time. I am expecting something like if I say javap java.lang.* it should enlist the methods and members of all t...

Java compiler handles inline Strings efficiently?

1. static final String memFriendly = "Efficiently stored String"; System.out.println(memFriendly); 2. System.out.println("Efficiently stored String"); Will Java compiler treat both (1 and 2) of these in the same manner? FYI: By efficiently I am referring to runtime memory utilization as well as code execution time. e.g. can the 1s...

How small can that JLabel be?

I have a JLabel that I need to draw off screen with some Transforms applied to the Graphics object. I'm trying to make the JLabel as small as it can be without ellipsis depending on its text content. What I'm trying to do is: setBounds(0, 0, label.getMinimumSize().width, label.getMinimumSize().height); Sometimes, this yields ellipsi...

Why are these Java enums changing values?

I'm having some trouble with making list of objects based on a condition on an enum. It seems that after I have completed the list, every item in the list is equivalent to the last item. It's the classic case of different references pointing to the same object, but I don't know how to avoid it: I've pared things down as much as I can ...

How to build without using locally installed artifacts

Is there any way to force Maven to use remote artifacts and not those installed on your machine? since I worry about runtime errors and not compilation errors build server is not valid option. P.S. I know I could delete or rename the .m2 folder, but I bet there is some more clever way of doing this. Maybe some plugin or special command ...

struts2 fileupload maximum file size

I'm using the fileUpload interceptor to upload files :). I've set a maximum file size as a interceptor parameter: <interceptor-ref name="defaultStack"> <param name="fileUpload.maximumSize">20000</param> </interceptor-ref> Now, I want to get this value in my input/form jsp. To have a message for example "upload the config file (max...

Sound Processing - Beat Matching Music Player on Android

Hey, So I want to make a new music player for Android, it's going to be open source and if you think this idea is any good feel free to let me know and maybe we can work on it. I know it's possible to speed up and slow down a song and normalize the sound so that the voices and instruments still hit the same pitch. I'd like to make a m...

Is there a standard Java utility to parse XSD files at runtime?

I've been looking around for a way to programmatically parse XSD files to generate an XML mapping so that I can take any XSD file and create a parser that will parse any XML file that conforms to it, and my google-fu has been coming up short. XSOM looks promising, as it will parse an XSD file and make all its attributes available in a ...

How do I setup log4j properties so that each thread outputs to its own log file?

Hello all, I have multiple instances of a thread class running at any given time. I have log4j setup to be used for logging needs. I need a way to setup log4j so that every instance of my thread class outputs its log in a different log file. Here is what I have done ( in pseudo code) public class doSomething extends Thread { pri...

What is the best book to get started with software design?

Possible Duplicates: What books do you suggest for understanding object oriented programming design deeply? What is the single most influential book every programmer should read? Best Java book you have read so far I am currently at university and am about to start a personal project, for both experience and hopefully to hel...

Can a client access the Corba IMR to get server information?

Is it possible for a client to access the IMR to get the host name of the servers? ...

How to load a resource bundle from a file resource?

I have a file called mybundle.txt in c:/temp - c:/temp/mybundle.txt how do I load this file into a java.util.resource bundle? The file is a valid resource bundle. This does not seem to work: java.net.URL resourceURL = null; String path = "c:/temp/mybundle.txt"; java.io.File fl = new java.io.File(path); try { resourceURL = fl.to...

Is there a market for JNI?

JNI is a peculiar little corner of the universe. I was wondering if there is a market there for specialty contract work. From what I can tell: (1) JNI usage is rather rare these days. (2) Most devs are not as good at it as they might think. (3) Being rare, it is a labor to come up to speed (again) when called upon to do so. The poten...

How can I make Maven set up (and keep up to date) the build path for my Eclipse project?

I define the dependencies for compiling, testing and running my programs in the pom.xml files. But Eclipse still has a separately configured build path, so whenever I change either, I have to manually update the other. I guess this is avoidable? How? ...