Skip to content

Tag: java

Network is unreachable?

I want to run a cyc (opencyc) Java class, but when I run this class I got an error mentioning that the network is unreachable. I am working on NetBeans 7.0 and opencyc 2.0 win 32 version. I am using localhost (127.0.0.1) to test. The error is below. Why is this happening? How can I connect to the cyc? Answer

How to use replaceValues method of Guava Multimap?

I want to add, remove and replace values in a MultiMap provided by Guava. I do this currently to add values.. Removing values is easier with Guava library. But how can I use the replaceValues method? I mean this Say I wanted to replace value 4.3 with a new value 5.99, how should I do that, the method expects …

Rounding with DecimalFormat in Java

Let’s look at the following statements in Java. In the above statements, all other cases are obvious except the following. It should return 3 but it returns 2. How? Answer This is intentional behavior. From the documentation: Rounding DecimalFormat uses half-even rounding (see ROUND_HALF_EVEN) for forma…

Date formatting according to country habbits

We create J2SE application that has to format the date and time according to custom the country from which users come from. I want to ask how to solve this thing in Java? Probably I’ll use SimpleDateFormat, but I wonder if it is possible to get format string in somehow simpler way than to have all forma…

How to create a .jar file using the terminal

I’m trying to create a .jar file using the mac terminal but am having bit of trouble. I followed the steps here but was unsuccessful. I got this error message: So how exactly do you go about doing it? My java program is called Main.java and I have compiled it into a .class file. Now what do I do? Thanks

for-loop very slow on Android device

I just ran into an issue while trying to write an bitmap-manipulating algo for an android device. I have a 1680×128 pixel Bitmap and need to apply a filter on it. But this very simple code-piece actually took almost 15-20 seconds to run on my Android device (xperia ray with a 1Ghz processor). So I tried …