I get maven error : Any idea how to solve this? Answer A quick search on Google seems to indicate that this error is related to the buildnumber-maven-plugin. However, I couldn’t reproduce the error on the command line on my machine (Maven 2.2.1, Java 1.6.0_16, svn 1.6.5 on GNU/Linux): From what I can se…
How to obtain all subsequence combinations of a String (in Java, or C++ etc)
Let’s say I’ve a string “12345” I should obtain all subsequence combinations of this string such as: –> 1 2 3 4 5 –> 12 13 14 15 23 24 25 34 35 45 –> 123 124 125 234 235 345 –> 1234 1235 1245 1345 2345 –> 12345 Please note that I grouped the…
Detecting cyclic dependencies with Maven
In my application I’m using an external library (Batik 1.7) that is made up of several modules. The modules have multiple cyclic dependencies between themselves. This doesn’t influence the build, but some tools (e.g. the M2Eclipse Dependency Graph, or the Dependencies report) will not work anymore…
How do I convert a byte array to a long in Java?
I am reading 8 bytes of data in from a hardware device. I need to convert them into a numeric value. I think I want to convert them to a long as that should fit 8 bytes. I am not very familiar with Java and low level data type operations. I seem to have two problems (apart from the fact
How to set classpath when I use javax.tools.JavaCompiler compile the source?
I use the class javax.tools.JavaCompiler (jdk6) to compile a source file, but the source file depends on some jar file. How to set the classpath of the javax.tools.JavaCompiler? Answer The javax.tools.JavaCompiler#getTask() method takes an options parameter that allows to set compiler options. The following m…
How to check internet access on Android? InetAddress never times out
I got a AsyncTask that is supposed to check the network access to a host name. But the doInBackground() is never timed out. Anyone have a clue? public class HostAvailabilityTask extends AsyncTask<…
JUnit: @Before only for some test methods?
I have some common set up code that I’ve factored out to a method marked with @Before. However, it is not necessary for all this code to run for every single test. Is there a way to mark it so the @Before method only runs before certain tests? Answer Just move out the tests that don’t need the set…
is there a equivalent of Java’s labelled break in C# or a workaround
I am converting some Java code to C# and have found a few labelled “break” statements (e.g.) label1: while (somethingA) { … while (somethingB) { if (condition) { …
How is Eclipse Mylyn useful?
In my Eclipse Preferences -> Java -> Editor -> Content Assist -> Advanced settings, I see the following: Java Non-Type Proposals Java Proposals Java Proposals (Task-focused) Java Type Proposals JPA Proposals (is always empty for me) PDE API Tools Proposals (gets skipped when checked in the Content…
How to find the index of an element in an array in Java?
I am looking to find the index of a given element, knowing its contents, in Java. I tried the following example, which does not work: Can anyone please explain what is wrong with this and what I need to do to fix it? Answer In this case, you could create e new String from your array of chars and then