Skip to content

Tag: java

Delete directories recursively in Java

Is there a way to delete entire directories recursively in Java? In the normal case it is possible to delete an empty directory. However when it comes to deleting entire directories with contents, it is not that simple anymore. How do you delete entire directories with contents in Java? Answer You should check out Apache’s commons-io. It has a FileUtils

Why am I getting this UnsatisfiedLinkError with native code?

I have a library called and a program with this content: Now when I try to run 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.loadLibrary( at java.lang.Runtime.loadLibrary0( at java.lang.System.loadLibrary( at HelloWorld.<clinit>( Any tips? Answer @mmyers Thank you for responding. We found out that all we had to

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 field, but many of

Best way to check whether a certain exception type was the cause (of a cause, etc …) in a nested exception?

I am writing some JUnit tests that verify that an exception of type MyCustomException is thrown. However, this exception is wrapped in other exceptions a number of times, e.g. in an InvocationTargetException, which in turn is wrapped in a RuntimeException. What’s the best way to determine whether MyCustomException somehow caused the exception that I actually catch? I would like to