Skip to content

Why am I getting this UnsatisfiedLinkError with native code?

I have a library called HelloWorld.so and a program HelloWorld.java with this content: Now when I try to run HelloWorld.java I get this error: $ /usr/java1.4/bin/java HelloWorld Exception in thread “main” java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path at java.lang.ClassLoader.l…

How do I put a Java app in the system tray?

I have a little control-panel, just a little application that I made. I would like to minimize/put the control-panel up/down with the systemicons, together with battery life, date, networks etc. Anyone that can give me a clue, link to a tutorial or something to read? Answer As of Java 6, this is supported in …

Does an open-ended interval implementation exist for Java?

I’ve got a classification of certain values in different intervals. Most have the form [20-30], but some are of the form [30-infinite). Is there an interval class you know of which can represent: an interval which is not closed on both sides (e.g. (0-5) or [0-5) ) an interval which closes (or starts) on…

Java FileReader encoding issue

I tried to use java.io.FileReader to read some text files and convert them into a string, but I found the result is wrongly encoded and not readable at all. Here’s my environment: Windows 2003, OS encoding: CP1252 Java 5.0 My files are UTF-8 encoded or CP1252 encoded, and some of them (UTF-8 encoded fil…

Is there a Null OutputStream in Java?

I need to specify an OutputStream for an API I’m using, but I don’t actually have a need for the output. Does Java have an OutputStream equivalent to > /dev/null? Answer Since Java 11, there is a static utility that does exactly what you need, a static factory method OutputStream.nullOutputStre…

Byte array of unknown length in java

I am constructing an array of bytes in java and I don’t know how long the array will be. I want some tool like Java’s StringBuffer that you can just call .append(byte b) or .append(byte[] buf) and have it buffer all my bytes and return to me a byte[] when I’m done. Is there a class that does…

Does JPA support mapping to sql views?

I’m currently using Eclipselink, but I know now days most JPA implementations have been pretty standardized. Is there a native way to map a JPA entity to a view? I am not looking to insert/update, but the question is really how to handle the @Id annotation. Every entity in the JPA world must have an ID …

getClassLoader().getResource() returns null

I have this test app: When I run it from Eclipse, I get the error: Classpath (from .CLASSPATH file) In my c:projectsrc folder, I have only the Test.java file and the ‘assets’ directory which contains pacman.png. What am I doing wrong and how to resolve it? Answer I would do it this way: “/as…