java

how to register url handler for apache commons httpclient

I want to be able to access custom URLs with apache httpclient. Something like this: HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("media:///squishy.jpg"); int statusCode = client.executeMethod(method); Can I somehow register a custom URL handler? Or should I just register one with Java, using URL.setURLStre...

Java 2D Drawing Optimal Performance

I'm in the process of writing a Java 2D game. I'm using the built-in Java 2D drawing libraries, drawing on a Graphics2D I acquire from a BufferStrategy from a Canvas in a JFrame (which is sometimes full-screened). The BufferStrategy is double-buffered. Repainting is done actively, via a timer. I'm having some performance issues though, e...

NoClassDefFoundError with a long classname on Tomcat with java 1.4.2_07-b05

Hi I have a java class. it.eng.ancona.view.RuoliView$TabElaborazioneFattureValidazione$ ElencoDettaglioElaborazioneFattureValidazione$RigaElencoDettaglioElaborazioneFattureValidazione (i break the line for better readable) Is so long for multiple inner class. If i use 1.4.2_07-b05 on Eclipse and i call this class, all go fine. If i...

Storing database data in files?

I'm currently working on a school project, in java, and I'm coding a database application. Something like the MySQL Monitor where you type in queries and get results / whatever. In applications I've coded before, I used databases to store data, like user profiles, settings, etc. Now, obviously, I can't use a database to store data gener...

Accessing constant values from an Apache Velocity template?

Is it possible to access a constant value (i.e. a public static final variable defined in a Java class) from a Velocity template? I would like to be able to write something like this: #if ($a lt Long.MAX_VALUE) but this is apparently not the right syntax. ...

Unloading classes in java?

I have a custom class loader so that a desktop application can dynamically start loading classes from an AppServer I need to talk to. We did this since the amount of jars that are required to do this are ridiculous (if we wanted to ship them). We also have version problems if we don't load the classes dynamically at run time from the App...

Scrollable JDesktopPane?

I'd like to add scrolling capability to a javax.swing.JDesktopPane. But wrapping in a javax.swing.JScrollPane does not produce the desired behavior. Searching the web shows that this has been an issue for quite some time. There are some solutions out there, but they seem to be pretty old, and I'm not not completely satisfied with them. ...

How to emulate C# as-operator in Java

There are situations, where it is practical to have a type-cast return a null value instead of throwing a ClassCastException. C# has the as operator to do this. Is there something equivalent available in Java so you don't have to explicitly check for the ClassCastException? ...

Loading animated gif from JAR file into ImageIcon

I'm trying to create a ImageIcon from a animated gif stored in a jar file. ImageIcon imageIcon = new ImageIcon(ImageIO.read(MyClass.class.getClassLoader().getResourceAsStream("animated.gif"))); The image loads, but only the first frame of the animated gif. The animation does not play. If I load the animated gif from a file on the f...

Best Books for Learning Java 6?

Hi, What are the Best Books for Learning Java 6? Regads, Srinivas ...

Package dependencies

What are the possibilities to enforce certain package dependencies in a java build system? E.g. the myapp.server.bl.Customer class not allowed to refer to the myapp.client.ui.customlayout package. I'm interested in either Ant or IDE-specific solutions. I'd like to get an error message in the build process indicating that a (custom) pac...

annotation based Spring bean validation

Hi, I'm investigating an annotation-based approach to validating Spring beans using spring modules. In this tutorial, the following bean (getters and setters omitted) is used as an example: public final class User { @NotBlank @Length(max = 80) private String name; @NotBlank @Email @Length(max = 80) private...

Is there an implementation of AJP protocole in Java ?

From Apache, you can use the "mod_jk" module to send http requests to Tomcat using the "AJP" protocole, which is far more efficient that http itself. I want to do the same, but from a Java program. I want to use "AJP" because of its good performances (and Tomcat is not bad after all). Of course, "google is my friend" (but I didn't find...

Naming conventions for threads?

It's helpful to name threads so one can sort out which threads are doing what for diagnostic and debugging purposes. Is there a particular naming convention for threads in a heavily multi-threaded application that works better than another? Any guidelines? What kind of information should go into the name for a thread? What have you lear...

Creating non-reverse-engineerable java programs

The title is essentially the question. Does anyone know of a way to deploy a Java program in a format that is not reverse-engineer-able? I know how to convert my application into an executable jar, but I want to make sure that the code cannot be reverse engineered, or at least, not easily. Obfuscation of the source code doesn't count.....

How do I list / export private keys from a keystore?

How do I list and export a private key from a keystore? ...

send e-mail and check status

Hi, Using Java mail, I would like to send an e-mail and check the status. Possible statuses include: Hard-bounce: No mail server found Soft-bounce: Mail server found, but account not found Success Is it even possible to send an e-mail and get some feedback about the delivery attempt in the manner I've described above? EDIT: A respo...

Using underscores in Java variables and method names

Even nowadays I often see underscores in Java variables and methods, an example are member variables (like "m_count" or "_count"). As far as I remember, to use underscores in these cases is called bad style by Sun. The only place they should be used is in constants (like in "public final static int IS_OKAY = 1;"), because constants shou...

Desktop Applications: Architectural Frameworks?

I'm wondering if there are any architectural frameworks out there to create desktop or standalone applications, in Java or C# for instance. It seems that there are tons of them available for web applications but I can't find many good resources on frameworks or architectural best-practices for desktop development. Ideally I would like t...

What is the minimum length number the luhn algorithm will work on?

Excluding the check digit, what is the minimum length number the luhn algorithm will work on? My thoughts are that it would work on any number greater than 2 digits (again, excluding the check digit). The reason I ask is this: if i iterates over all digits in the number from right to left. This causes i%2 == 0 (used to find alternate...