java

Java Robot createScreenCapture performance

I need to grab a series of screenshots and concatenate them into a movie. I'm trying to use the java Robot class to capture the screen. But the createScreenCapture() method takes more than 1 second on my machine. I can't even get 1 fps. Is there a way to speed it up? Or is there any other API? Edit: It is allocating a buffered image. ...

How to set the execution directory with JCreator (Pro)?

Is it possible, to execute a class in a specified directory? I mean, a.class is in directory abc and i want it to be executed as if it were in directory xyz (directly from the IDE of JCreator). ...

Why did I get "FileUploadException: Stream ended unexpectedly" with Apache Commons FileUpload?

What is the reason for encountering this Exception: org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly ...

How does one store password hashes securely in memory, when creating accounts?

Our web-based applications has user accounts tied down to users with the passwords specified during account creation. In the case of Java, how does one process the password securely, before persisting its hash in the database. To be more specific, how does one ensure that the string holding the password is garbage collected within a suf...

How do I redirect to a html page and pass variables to that page in Java?

Hello all, I have a form on my index.html page which makes a POST request to a Java Servlet. This servlet does some processing and I would like to redirect back to index.html with some variables that the servlet has produced. In PHP, it would be as simple as: header("Location: index.html?var1=a&var2=b"); How can I acheive the same w...

Why do JList selections occur twice?

I have a JList with some items. I've added a listener for when a item in the list is selected. Here is the code for what happens when an item in the list is selected: private void questionaireNamesListValueChanged(javax.swing.event.ListSelectionEvent evt) { try { inputPa...

Using the JDK LDAP library, how can I add more than one description?

I can add two descriptions (attribute) using my IDE, but from Java I can only add one description. How to add the second one? I'm using the JDK LDAP library. ...

Axis2 Session Managment

Hi, iam building a small webservice in axis2 (buttom up, i write the java classes and let eclipse wtp generate the service). I would like to use sessions so that a user can login with a username and pass if it exist in a database and than use the webservice but within the context of his session. I quite frankly don't know where to start....

How to implement the logging between the flow of the existing application

I have an application in which we have already a logger file. But i need to implement that logging into one of the process flow. Where I need to write the code for logging for this process flow? ...

Is there a good J2ME IDE?

Is there a good J2ME IDE? I mean something lightweight, and portable. Something that can run what you program on it. My favorite Java IDE is JCreator Lite. Is there something like that for J2ME? Also, which would you say is the best J2ME IDE? ...

How can I implement an algorithm for multicore in Java?

Modern computers have more and more cores. We want to change our current linear algorithm to use these cores. A splitting of any algorithm to use different threads only makes sense if there is a free processor. Are there any good libraries that can help to parallelize some steps if there are free processors? I will give some examples....

Strange ClassCastException

This: Timerange longest = Timerange.longest(breaks); if (longest.durationInHours() >= MIN_FREE_HOURS) return true; is OK. But this: if (Timerange.longest(breaks).durationInHours() >= MIN_FREE_HOURS) return true; gives: java.lang.ClassCastException Do you know why?! For simplicity: public static final <T extends Timera...

why does java's inputstream.close() block?

My Java program uses ProcessBuilder (with redirectErrorStream set true) and has a loop that runs the processes's inputstream's read method, which is blocking. The external program I'm calling then comes to a stop waiting for input og stdin. I now want to kill the process. Is this not done by (in a seperate thread) calling the process's d...

What do you think of my simple Java class that encrypts text into SHA-1?

Anyway I'm starting out to make Java programs (a programming newb) and I've decide to do a simple utility class that converts text into SHA-1 strings. I'm planning on using this to encrypt passwords for databases. Feel free to comment and I'd love to learn from you guys. Here's my code: /* * Utility class that encrypts a string created...

Is it possible to wait for methods that aren't in Threads to finish in Java?

I have an object which does some computation, then for each iteraction I want to draw what happens. While the drawing is happening, I want it to wait. This is what I did, basically: synchronized public void compute() { other.mark(variable); try { wait(); } catch(InterruptedException e) { } } in the...

Java Abstract Class Confusion.

Hi, So I have two classes. One is abstract: public abstract class AbstractClient { protected boolean running = true; protected void run() { Scanner scanner = new Scanner(System.in); displayOptions(); while (running) { String input = null; while (scanner.hasNext()) { ...

newInstance() vs new

Is there a penalty for calling newInstance() or is it the same mechanism underneath? How much overhead if any does newInstance() have over the new keyword* ? *: Discounting the fact that newInstance() implies using reflection. ...

How do you escape curly braces in javadoc inline tags, such as the {@code} tag.

/** * Gets the meatball icon for a nincompoop. * * <p> * Example: {@code <custom:meatball color="<%= Meatball.RED %> nincompoop="${person}" />} * * @author King Cong * */ The "${person}" part breaks the doc comment because it uses curly braces. Thanks in advance, LES ...

Using Sound Effects in a java game

Basically I am trying to use this SoundEffect class in a simple java game I'm working on for my assignment. import java.io.*; import java.net.URL; import javax.sound.sampled.*; /** * This enum encapsulates all the sound effects of a game, so as to separate the sound playing * codes from the game codes. * 1. Define all your sound eff...

Is the original Java ideal dead?

I feel that while I love J2ME and Java it's hypocritical of them to have two APIs for Java. Java was designed with "One code, many platforms" in mind, and now it's more like "One API for every OS, and one API for everything smaller than a netbook." I see a lot of J2ME emulators and such being ported to things like the PSP, and other cons...