java

Casting a Object to HashMap

Hello there, I'm having trouble working out how to count instances of Values in a HashMap. I have seen that there is methods attached to the Object class that look as if they are able to help me, so I've tried to cast those in to work but I must be doing something wrong somewhere. If there's an easier way, I haven't found it yet. NB: L...

log4j configuration via JVM argument(s)?

What variables to I have to set/pass as arguments to the JVM to get log4j to run properly? And by properly I mean as in just not complain and print to the console. Can I see a typical example? Note: I need to avoid creating a lo4j.properties file in the application. ...

Java Performance Degradation on removing locks

I am testing my java application for any performance bottlenecks. The application uses concurrent.jar for locking purposes. I have a high computation call which calls lock and unlock functions for its operations. On removing the lock-unlock mechanism from the code, I have seen the performance degradation by multiple folds contrary to my...

Enumerating attached DVD drives in Linux / Java / Scala

In my Scala (runs on top of Java) Application I would like to get a list of all drives that contain DVD media, e.g. something like this: /dev/scd0 Star Trek DS9 DVD1 /dev/scd0 The 4400 DVD1 Not sure if it's possible to get the name of the disc, but the path is the important thing for me anyway. I would prefer a pure Java / Sca...

Vast difference in Java Performance from 1.4 to 1.6

I have observed a great difference in Sun Java performance when code is compiled through jdk1.6 as compared to jdk1.5 or jdk1.4 (over 4 folds) What changes and optimizations have been done? Is there anything worth taking home from these changes which will help to boost our application performance. Thanks for replying ...

Eliminating Javac warnings for JSPs in Jasper generated Java source files?

When pre-compiling JSPs with the Jasper compiler (using Tomcat), and then the Java compiler I see javac warnings like this (I have javac's -Xlint flag enabled): warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List _jspx_dependants.add("/some-jsp.jspf"); Now, it's "just a warning," but I like clean b...

increase JRun launch time

Hi, If you try to launch a JRun server and initialization takes more than 30 secs, the launch fails. Is there any way to increase this 30 second limit? Thanks, Tony ...

How can I set RenderingHints globally?

For a Java application, can I set the RenderingHints on a global basis? Currently, I've defined these in the paintComponent method as shown below. I would prefer, however, to set them once when the application starts and have them persist throughout the session. @Override protected void paintComponent(Graphics g) { super.paintComponent(...

Simplest way to stop all java threads from disappearing into IO ?

I have a web-application that only requires the servlet-container to run. My login page and front page do not have any backend transactions, but all others do. What'd be the simplest way to guarantee that I don't send all my threads into some socket wait for a backend system (CXF-webservices) ? This is weblogic 10.3 but I'm really not th...

Is there a cross-platform GUI framework for C#/.NET?

Let's say just for the joy of it, I decide that I don't want to write desktop applications in Java any more, instead want to switch to using C#. I want to be able to build an application that will run on some mainstream Linux distribution, and a recent release of MS Windows. It will have a GUI component. In Java I can build an applic...

Die you threadpoolexecutor

I have a java.util.concurrent.Execution service - a single threaded thread pool executor. I submit certain tasks to it. If the task throws an unchecked exception the thread dies but the service ensures that a new thread is spawned and subsequent tasks are performed in that. However I do not want this feature and still want to use a threa...

Reflection and multi dimensional arrays

I have code that uses reflection on an input object and does some processing on the data stored in the object. The input object can be anything like String or int or double etc., sometimes it can be a multi dimensional array. I know how to do it for two dimensional arrays but I would prefer something that would work for any given dimensi...

JSP or JavaScript equivalent to PHP's $_SERVER["HTTP_HOST"]?

I've go an absolute URL in my JavaScript that I have hard coded for window.location. I don't want to have to change this every time I am testing my app. In PHP I would have handled this by testing the $_SERVER["HTTP_HOST"] variable to find out what server I am on, and adjust accordingly. However, I'm not as familiar with Java and am won...

Java generics Pair<String, String> stored in HashMap not retrieving key->value properly

Here's Pair.java import java.lang.*; import java.util.*; public class Pair<TYPEA, TYPEB> implements Comparable< Pair<TYPEA, TYPEB> > { protected final TYPEA Key_; protected final TYPEB Value_; public Pair(TYPEA key, TYPEB value) { Key_ = key; Value_ = value; } public TYPEA getKey() { return Key_; } public...

How do I write an application that more or less acts as a container?

I am planning an application that must provide services that are very much like those of a JEE container to third party extension code. Basically, what this app does is find a set of work items (currently, the plan is to use Hibernate) and dispatch them to work item consumers. The work item consumers load the item details, invoke third...

Reverse engineer DDL from JPA entities

I'm playing around with some JPA stuff, changing the mappings to see how they're supposed to be etc. It's basic experimentation. However I can't find a tool that will simply read my entities and then generate the table schema for me. I tried to find something like this in JBoss tools but nada. Eclipse integration will be a huge plus but ...

Delete files recursively in Java

Is there a way to delete entire directories recursively in Java? In the normal case it is possible to delete an empty directory. However when it comes to deleting entire directories with contents, it is not that simple anymore. How do you delete entire directories with contents in Java? ...

Resin Server Exception

What would be the possible causes for the below exception on resin server restart? 500 Servlet Exception conf/resin.conf:168: java.lang.StackOverflowError Resin Professional 3.0.21 (built Thu, 10 Aug 2006 12:17:46 PDT) ...

Where on the file system was my java class loaded from?

I think this is a situation every java programmer runs into if they do it long enough. Your doing some debugging and make a changes to class. When you go to re-run the program, these changes don't seem to be picked up but rather the old class still seems to be running. you clean and rebuild everything, same issue. Sometimes, this can...

How do I convert XML into a java value object?

What kind of open-source libraries are available to convert XML into a java value object? In .Net, there is a way to easily do this with xml serialization and attributes. I would imagine there some parallel in java. I know how to do this with a DOM or SAX parser, but I was wondering if there was an easier way. I have a predefined XML ...