java

Decode Base64 data in java

I have an image that is base64 encoded. What is the best way to decode that in Java? Hopefully using only the libraries included with Sun Java 6. ...

How do I correctly decode unicode parameters passed to a servlet

Suppose I have: <a href="http://www.yahoo.com/" target="_yahoo" title="Yahoo!&#8482;" onclick="return gateway(this);">Yahoo!</a> <script type="text/javascript"> function gateway(lnk) { window.open(SERVLET + '?external_link=' + encodeURIComponent(lnk.href) + '&external_target=' + encodeURIComponent(lnk.target) + ...

Is there a cron-like implementation of ScheduledExecutorService in Java?

The ScheduledExecutorService in Java is pretty handy for repeating tasks with either fixed intervals or fixed delay. I was wondering if there is an something like the existing ScheduledExecutorService that lets you specify a time of day to schedule the task at, rather than an interval i.e. "I want this task to fire at 10am each day". I ...

Java openmpi

Is there a current Java openmpi implementation. I have programmed in MPI a bit, and I enjoy programming in Java. I have seen this implementation in java, but it seems dated. Is there a more up to date java implementation that is being kept up? ...

JAXB Documentation Annotation

I have the following java class with the JAXB @XMLRootElement annotation @XmlRootElement(name="ClientData") public class ClientData { /** * The first address field of the person */ private String address1 = null; } which produces this xml fragment when i generate the xsd schema <xs:complexType name="clientData"> <xs:sequence> ...

move Hudson job to another server

Hi, I've setup a continuous integration build with Hudson running on Tomcat. I now need to move this a different instance of Tomcat, but don't want to have to configure everything from scratch. Is there a configuration file that defines each job which I could copy to the new server, or is to possible to import/export a job via the user...

Java generics and array initialization

What's the explanation for the following: public class GenericsTest { //statement 1 public ArrayList<Integer>[] lists; public GenericsTest() { //statement 2 lists = new ArrayList<Integer>[4]; } } The compiler accepts statement 1. Statement 2 is flagged by the compiler for "generic array creation"....

java.util.logging.Logger doesn't respect java.util.logging.Level ?

In plain JSE 6 environment: Logger l = Logger.getLogger("nameless"); l.setLevel(Level.ALL); l.fine("somemessage"); Nothing shows up in Eclipse console. l.info("") and above works just fine, but anything below fine just doesn't seem to work. What's could be wrong? TIA. ...

How do I attach properties files to a jar?

I have a project that uses the serial port, and it requires two files to run, the win32.dll file (which is in the java runtime environment bin folder) and the javax.comm.properties file (which is in the java runtime environment lib folder). When I run the project from eclipse it works, but when I try to build a jar file for distribution,...

Defining classes in Java files

I have found one error in my Java program: The public type abc class must be defined in its own class How can I resolve this error? I am using Eclipse. I am new to Java programming. ...

How to programmaticaly import Java class

Is there a way in Java to programmatically import a class given its full name as a String (i.e. like "com.mydummypackage.MyClass")? ...

Intellij IDEA setup on OS X

What's the accepted procedure and paths to configure jdk and global library source code for Intellij IDEA on OS X? ...

Jython and python modules

I've just started using the PythonInterpreter from within my Java classes, and it works great! However, if I try to include python modules (re, HTMLParser, etc.), I'm receiving the following exception (for re): Exception in thread "main" Traceback (innermost last): File "", line 1, in ? ImportError: no module named re How could I m...

Java - Easier way to guarantee integer input through Scanner?

For a program I am writing, I need to ask a user for an integer between 1 and 8. I've tried multiple (cleaner) ways of doing this but none of them worked, so I'm left with this: int x = 0; while (x < 1 || x > 8) { System.out.print("Please enter integer (1-8): "); try { x = Integer.par...

java sound fade out

Hi. Using javax.sound.sampled, I want to fade out a sound I started looping infinitely. This is how I started the sound: Clip clip = AudioSystem.getClip(); AudioInputStream inputStream = AudioSystem .getAudioInputStream(new File("x.wav")); clip.open(inputStream); clip.loop(clip.LOOP_CONTINUOUSLY); Could anyone point me to how I can do...

Java code or lib to decode a binary-coded decimal (BCD) from a String

I have a string consisting of 1's ('\u0031') and 0's('\u0030') that represents a BCD value. Specifically, the string is 112 characters worth of 1's and 0's and I need to extract either 8 or 16 of these at a time and decode them from BCD to decimal. Ideas? Packages? Libs? Code? Snooty remarks about my sheer fucking laziness? All is welc...

How can "while (i == i) ;" be a non-infinite loop?

I just got a question that I can't answer. Suppose you have this loop definition in Java: while (i == i) ; What is the type of i and the value of i if the loop is not an infinite loop and the program is using only one thread? ...

Call hierarchy of Thread.run() in Eclipse

I tend to use eclipse's "Open Call Hierarchy" function a lot, to trace where method calls are going in larger Java projects. I get irritated by Threads, as the call hierarchy shows the callers of the Thread.run() method as various internal Java threading functions, rather than the Thread.start() call which effectively led to the thread b...

Java Socket Programming

I am building a simple client/server application using java sockets and experimenting with the ObjectOutputStream etc. I have been following the tutorial at this url http://java.sun.com/developer/technicalArticles/ALT/sockets starting half way down when it talks about transporting objects over sockets. See my code for the client http:/...

Tips for moving from C# to Java?

So I'm going to a job interview next week at a Java place, and would like to not come across as clueless. I'm a pretty confident C#/.NET developer and am (clearly!) willing to consider jumping ship to Java - I'd like links to resources people would recommend for doing this. I'm interested in answers to questions like: Any guides that...