java

Reading from input file in command line

Hi, This time I have a very lame problem, which was working perfectly but now its not: BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); while (br.readLine() != null) { System.out.println(br.readLine()); } Input file: 1 2 3 4 5 6 7 8 9 In command line: ...

Allowing users to script inline, what inline scripting engines are there for either .net or java?

Are there any open source scripting engines that allow you to give your users the ability to perform light scripting on pages via a web based interface? (some objects/collections would be pre-populated, and have security in place so users can't hack into the web application's inner workings etc.) Examples: http://wiki.shopify.com/Usin...

PNG transparency without alpha channel

I am trying to create a transparent PNG image from a BufferedImage in Java. The PNG will be loaded into another piece of the software, that does not support the alpha channel. That should be fine, because, according to Chapter 8, section 5, part 4 of the PNG book, I can achieve transparency by specifying a pixel value to be transpare...

In Java, how to get the difference between 2 dates in seconds?

The Java class library has a class named DateTime. DateTime has this method: int daysBetween(DateTime other) which returns the number of days between this and the parameter. It doesn't have a method int secondsBetween(DateTime other) which I happen to need. Is there a class which is similar to DateTime but has such a method? ...

Is a signed Android APK-File running on x86- and ARM-Android devices?

Android APK-Files are not binaries but byte-code-files. So is it possible to install the same APK-File on both - on x86-Android-Devices and ARM-Android-Devices? There are some x86-Netbooks with Android installed planned and I wonder if it is possible to run the APK-Files on both kinds of devices? Best regards, Tom ...

Servlet Filter vs. ServletRequestListener

I want to bind a JPA EntityManager to the current thread on each request (via ThreadLocal), what could be done via a ServletRequestListener or Filter. The listener looks cleaner and I don't need the additional possibilities of a filter in this case. But maybe the filter has an advantage I've missed. Should I use a Servlet Filter or a Se...

How do "modern JVMs" differ from older JVMs?

Here's a phrase that I heard a lot throughout high school and university computer science classes: "That's not an issue for modern JVMs." Usually this would come up in discussions about overall performance or optimization strategies. It was always treated as a kind of magical final answer, though, as if it makes issues no longer w...

What's the host param in applets for if when we can use codebase?

what's are the uses of the host param with java applets? can it be tricked to use a different server than the originating server? I didn't find a clear complete explanation of the host param. ...

Is it possible to handle User Defined Exception using JAX WS Dispatch API ?

Hello, I'm performing dynamic webservices call using following code snippet: JAXBContext jc = getJAXBContext(requestClass, responseClass, jaxbContextExtraClasses); Dispatch<Object> dispatch = service.createDispatch(portQName, jc, Service.Mode.PAYLOAD); Object requestValue = getRequestValue(requestClass, pOrderedParameters...

Reinitialize log4j on web app deployment using Log4jConfigListener

Hello, I have setup Log4jConfigListener in my web.xml and it works fine, however, if I redeploy the web app without restarting the server then log4j shuts down and does not reinitialize. If I remove the Log4jConfigListener from my web.xml then everything works fine. I am using JBoss 4.2.3-GA as the app server. I notice that when I am...

Simple hash function (1 byte output from string input)

Hi folks, I'm looking for a simple hash algroithm that will give me one byte of output for a string input (the inputs will be RFC822 email addresses, if that helps). I'd like it to be simple, fast, and to magnify input differences (so two similar addresses have differnt outputs). (Yes, I am asking for a lot in one byte of output.) Id...

Resource Leakage in Play Wav Sound Sample Code

From http://stackoverflow.com/questions/26305/how-can-i-play-sound-in-java Is it possible to have resouce leakage for the following code? Who will be responsible to close the audio stream? public static void playAlertSound() { new Thread(new Runnable() { @Override public void run() { try { ...

Running other java versions on OSX

Sorry if this seems like it's for SuperUser. I just deleted it there :) I am running this command on OSX /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin/java -version and the response is java version "1.6.0_17" Is there any way to really run an older version of Java without downloading to a makeshift location? OS...

Post information to server and receive XML

On my web server I will be creating a bespoke XML file for a client app to access. This means I must authenticate the client and then give the client the XML file. I believe the client application will need to post data (login, password) to the server and once a connection is established, it will receive the XML file from the server (m...

Reference to Public Enum results in Anonymous Class

I'm getting an anonymous class at compile-time that I'm not expecting. Relevant code follows, then a more detailed explanation: Entirety of CircuitType.java: public enum CircuitType { V110A20, V110A30, V208A20, V208A30 } From Auditor.java, lines 3-9: public class Auditor { private String[] fileNames; private int numV110A20; ...

Coding to interfaces?

I want to solidify my understanding of the "coding to interface" concept. As I understand it, one creates interfaces to delineate expected functionality, and then implements these "contracts" in concrete classes. To use the interface one can simply call the methods on an instance of the concrete class. The obvious benefit is knowing of ...

java web applicaton layout, please explain some design principles/patterns

I'm looking at this java web application that is using hibernate, jsp's, and spring framework. (from what I can tell!) the file layout is like this: classes/com/example/project1 inside project1 /dao _entity_Dao.java /dao/hibernate/ _entity_DaoHibernate.java /factory DaoFactory.java DaoFactoryImpl.java /managers ...

System Tray (Menu Extras) icon in Mac Os using Java

I'm developing a desktop application using Java. I want to put an icon (with a contextual menu) on the system tray (called Menu Extras in Mac Os). Java 6 comes with support for doing this in Windows and Linux, but it doesn't work in Mac Os. I have seen some applications doing what I want in all three operating systems (e.g. DropBox), bu...

Is it possible developing a evolution (mail client) plugin in Java?

I have to write a plugin for Evolution and I'm studying the different possibilities. The documentation says that eplugin feature is independent from the language you choose but I've only seen Evolution plugins developed in plain C and a few in C#/Mono. I suppose that It's not possible using Sun VM because of GTK. Am I wrong? And, what...

How to throw an exception out of my java bean

I use a javaBean in my jsp-application to store form values. This is how I get my values into my bean. This code is part of my form.jsp try { <jsp:setProperty name="formparam" property="*" /> } catch (Exception e){ error = true; } I left the "<%" out to not break the code display on stackoverflow. Now I get my exception ...