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…
How to clone ArrayList and also clone its contents?
How can I clone an ArrayList and also clone its items in Java? For example I have: And I would expect that objects in clonedList are not the same as in dogs list. Answer You will need to iterate on the items, and clone them one by one, putting the clones in your result array as you go. For that
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…
What are real world examples of when Linked Lists should be used?
Another programmer was mentioning that they haven’t found a use case for using a linked list data structure in any professional software in his career. I couldn’t think of any good examples off the top of my head. He is mostly a C# and Java developer Can anyone give some examples where this was th…
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…