java

Using jetty to install and run servlet tests programmatically

The jetty servlet container is quick and light enough to run in unit tests (indeed I do to serve up files). It is possible to install actual servlets into it, programmatically (say in a test) and have it run them? ...

Applet loading problem with Win2003 Terminal Server

Applet loading seem to fail with JAVA 1.6 to error java.lang.ClassNotFoundException: at sun.applet.AppletClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) I believe this is related to limited security of user accounts under Win2003. Any ideas? The site is trusted. It works with ADMINISTRAT...

Instantiating an inner class

I have a utility method and when irrelevant logic is removed from it, the simplified method would look like this: public static <A extends Foo> List<A> getFooList(Class<A> clazz) { List<A> returnValue = new ArrayList<A>(); for(int i=0; i < 5; i++) { A object = clazz.newInstance(); returnValue.add(object); } re...

Java: How can I add a JMenu to a JPanel or create a drop down button?

Hello, is there any way to add a JMenuItem to a JPanel so that I can create a button to show multiple options, like the latest news button in firefox, under the address bar? I can only add JMenu and JMenuItems to a JMenuBar, JPopupMenu and other JMenus and JMenuitems Is there any way to create in Java Swing a drop down Jbutton? (the on...

Java Applet Closes IE for Users not Admins - where is JAVAPOLICY.EXE file ?

I have issue with Win2003 that Java Applet Closes IE for Users not Admins. I found out the following solution but it refers to missing JAVAPOLICY.EXE file: http://www.experts-exchange.com/Programming/Languages/Java/J2SE/Q_22694925.html where is this javapolicy.exe file, its not included with newest JRE6 ? ...

Client-server solution for signing and encrypting files

I'm looking for a solution to perform file encrypting and signing. This would be done on the client side, and signature check and decryption on the server side. Some details: This should work for any kind of file (the signature should be "attached" to the file, not inside it like with PDFs) At least the server side should be Java base...

Spring Security: What is the UserDetailsManager interface used for? And more!

I'm curious about the UserDetailsManager interface. It's not mentioned in the reference guide and in the JavaDoc it's described as: An extension of the UserDetailsService which provides the ability to create new users and update existing ones. When implementing the UserDetailsManager interface you have to implement five meth...

error with FileOutputStream

I'm having trouble with the following code. I'm trying to write to a .ppm file, and I get "Red.java:6: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown" FileOutputStream fout = new FileOutputStream(fileName); ^ Any ideas? import java.io.*; public class Red { ...

bytecode instrumentation using ClassFileTransformer.transform

I have written a Class with premain method and inside that method I have added a ClassFileTransformer to Instrumentation (Instrumentation.addTransformer()). I have invoked a application using java -javaagent:<path_to_agnet.jar> <application> However ClassFileTransformer.transform() method is not being invoked. I have observed that p...

Simple graphic display or display widget for Java

We're giving a demo in about a week of a program which calculates a couple of moving averages. It would be much cooler if we could display these averages graphically, like perfmon, instead of printing to the console. I'm looking for the fastest, easiest way to get this dynamic line-graph display onto a GUI ), the less programming require...

Does XtUnit support performance testing?

Does XtUnit support performance testing? ...

Concise explanations of Java language changes in the major revisions

I'm about to jump into Java development again after a number of years. The language revision I worked with was 1.4.2. I know there have been significant changes to the language since then, and I'm looking for a site or a book that covers these in some detail. At the very least, I'm looking for a resource that indicates which language fea...

Eclipse MyLyn with BugZilla: Will the BugZilla installation need to be modified/configured?

Hi, I'm interested in MyLyn. I'm using Eclipse Ganymede and I have access to a BugZilla installation for the project I'm working on. I wonder if the BugZilla installation will have to be changed/configured in any way or if I'm able to use MyLyn against it "out of the box"? Will I have to setup some special kind of MyLyn server or could...

Convert String XML fragment to Document Node in Java

In Java how can you convert a String that represents a fragment of XML for insertion into an XML document? e.g. String newNode = "<node>value</node>"; // Convert this to XML Then insert this node into an org.w3c.dom.Document at as the child of a given node? ...

Fill-in color on triangle using mouse click

I was wondering how to fill in a triangle shape with color when a user click on the triangle. So far I am using txt file as input file to read the coordinate of the triangle to be drawn on screen. ...

Good Ajax framework for J2EE

I'm relatively new to J2EE and I'm in need of a framework that will simplify AJAX for me. At the moment I have code that uses the dojo toolkit to draw a graph, but I'd like to have the graph updatable via AJAX. is there a good framework that allows me to do Ajax call backs and insert and run javascript into a page? If so is there a goo...

Struts2, best practice for using method={1}

I'm new to Struts 2 and I've come across this syntax (recommended in the tutorial). <action name="Register_*" method="{1}" class="Register"> <result name="input">/member/Register.jsp</result> <result type="redirectAction">Menu</result> </action> I understand that it calls Register.{1} method. The problem is a user could put in...

Prohibit direct extension of Java class outside its package

I have a package with a public abstract class Player { /*...*/ } and these public abstract class GamePlayer extends Player { /*...*/ } public abstract class TournamentPlayer extends Player { /*...*/ } public abstract class StatelessPlayer extends Player { /*...*/ } Users of the package need Players but in order to use the package w...

Java type cannot be resolved

I have a statement String pass = com.liferay.portal.util.PortalUtil.getUserPassword( renderRequest) that causes the following error in eclipse IDE: The type javax.servlet.http.HttpSession cannot be resolved. It is indirectly referenced from required .class files Why is this error occuring? I have added an import stat...

Which one of the major operating systems is best suited for a quick boot and startup of a Java application?

I created a Java application which is the only application active on a workstation. (Similar to a kiosk system) The problem is that the application has to be up and running as fast as possible after starting the computer. I'm wondering which one of the major operating systems can be configured to provide the shortest startup time? I'm...