java

NamingException when trying RMI/HTTP from JBoss 4.0.1 to 4.2.3

I've got an application that is trying to call a method on an EJB running on JBoss 4.2.3 GA. The application is a legacy app; it works when it accesses the original server which ran on JBoss 4.0.1. Its RMI code is in jbossall-client.jar from JBoss 4.0.1. It is trying to call a method which will give it new code to allow it to update it...

How to retrieve all the values associated with a key?

I want to get all the values associated with a key in Map. For e.g, Map tempMap = new HashMap(); tempMap.put("1","X"); tempMap.put("2","Y"); tempMap.put("3","Z"); tempMap.put("1","ABC"); tempMap.put("2","RR"); tempMap.put("1","RT"); How to retrieve all the values associated with key 1 ? ...

Editing xhtml jsp files in Eclipse

I've got some jsp files that are supposed to output xhtml. They seem to have the correct doctype etc but Eclipse is not parsing the xhtml attributes. For instance for the root element: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> I get the warning: "Undefined attribute name (xmlns)." What's the best way to solve...

Java: "implements Runnable" vs. "extends Thread"

From what time I've spent with threads in Java, I've found these two ways to write threads. public class ThreadA implements Runnable { public void run() { //Code } } //with a "new Thread(threadA).start()" call public class ThreadB extends Thread { public ThreadB() { super("ThreadB"); } public void run() {...

How to determine an object's class (in Java) ?

If class B and class C extend class A and I have an object of type B or C, how can I determine which it instantiates? ...

Estimate pixels of proportional font in SVG or Java

Is there an way to estimate the number of pixels used by a proportional font? I am writing software that creates an image in SVG and transform that to PNG in Java. In this image I am using a text with a proportional font (size 16). I can sometimes fit 26 characters in the picture and sometimes only 19. This is because 'WWW' takes much m...

How do I make controls autosizing in Qt designer?

I'm using Qt Jambi 4.4 for a project I'm working on (and designing the windows in the Qt Designer eclipse plugin). One of the windows I'd like to use is a preview window which is basically just a window with a QWebView on it. How can I make it so that the QWebView resizes as the window does? I've set the sizePolicy to expanding for bo...

Know of any Java garbage collection log analysis tools?

I'm looking for a tool or a script that will take the console log from my web app, parse out the garbage collection information and display it in a meaningful way. I'm starting up on a Sun Java 1.4.2 JVM with the following flags: -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails The log output looks like this: 54.736: [Full GC ...

Interface naming in Java

Most OO languages prefix their interface names with a capital I, why does Java not do this? What was the rationale for not following this convention? To demonstrate what I mean, if I wanted to have a User interface and a User implementation I'd have two choices in Java: Class = User, Interface = UserInterface Class = UserImpl,...

Multiple line code example in Javadoc comment

I have a small code example I want to include in the Javadoc comment for a method. /** * -- ex: looping through List of Map objects -- * <code> * for (int i = 0; i < list.size(); i++) { * Map map = (Map)list.get(i); * System.out.println(map.get("wordID")); * System.out.println(map.get("word")); * } * </code> * ...

Custom DateFormats mmm:ss

Is there a way to format a date to have mmm:ss instead of hh:mm:ss? Basically, 7:15:28 should show up instead as 435:28 instead. The SimpleDateFormat class does not support this format is there one that does or will I have to implement a variation myself? ...

JSP - Saving a collection

[Warning] I'm new to JSP/Struts/JSTL. This is probably a newbie question :) I have a form that contains a collection: public class ServiceForm extends AbstractForm { private List<SrvDO> allSrv = new ArrayList<SrvDO> (); } I can see the object data correctly in my form using the JSP. The page displays 5 input box with the dat...

Extracting files from a Jar more efficently.

I'm extending a utility class that bundles a set of images and .xml description files. Currently I keep all the files in a directory and load them from there. The directory looks like this: 8.png 8.xml 9.png 9.xml 10.png 10.xml ... ... 50.png 50.xml ... Here's my current constructor. It is lightning fast and does what I need it to...

Text cleaning and replacement: delete \n from a text in Java

I'm cleaning an incoming text in my Java code. The text includes a lot of "\n", but not as in a new line, but literally "\n". I was using replaceAll() from the String class, but haven't been able to delete the "\n". This doesn't seem to work: String string; string = string.replaceAll("\\n", ""); Neither does this: String string; stri...

Java's AWT or Swing for GUI construction?

I need to compose a fairly simple GUI for a server monitoring process. It will have a few tabs which lead to a log tailing, counts of resources, and a start and top control. Nothing fancy here. Which Java framework, AWT or Swing, makes more sense for something this simple. ...

Why do I get an AbstractMethodError when setting a JSTL variable?

I am trying to set a variable that I will refer to in a custom JSP tag, so I have something like this in my JSP: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="path" value="test"/> However, I am getting this error when The JSP runs: java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContex...

Video Streaming Server on Mobile

I have seen video streaming to mobile phones. I would like to know whether we have a streaming server that can be installed on mobile phone and stream video to another device from the camera present on the phone. I would like to have on for my Nokia N70 phone. ...

How would I write a Java regex that gets the contents of a <script> tag?

I'm trying to integrate analytics into my GWT application. To do this, I'm calling a service that returns a String of HTML that needs to be parsed and eval'ed. I need a regex that looks for and grabs either 1) the body of the tag or 2) the contents of the "src" attribute. I want to eval both of these with JavaScript. I'm happy with as...

How to reset or kill JVM context?

I am running a simple java client through java <class file> command. The java command is actually invoked by a system process. This is on Unix. We were facing problem with X11 Display. So we added export DISPLAY=:0.0 in the startup file and the Display problem was resolved. Now when the export DISPLAY=:0.0 line is removed from the start...

How can I access an HSQL DB from a .NET application?

Is it possible to access an HSQLDB database that is running in server mode from a .net application located on the same computer? There do not seem to be any odbc drivers for hsqldb (freely available). Am I missing it? Sun's jdbc odbc bridge seems to allow connecting to an odbc datasource through a jdbc connection, but I would need the...