Why is my shutdownhook in my main method not called?

I have the following in my main method: public static void main(String[] args) throws IOException { Properties properties = getConfig(); Jedis jedis = configure(properties) jedis.subscribe(queueHandler, "queue"); Runtime.getRuntime().addShutdown

Sort int in JTable

I want to sort a column with int in it in a JTable. I use TableRowSorter with the sort order SortOrder.ASCENDING. But somehow it sorts not how I actually want it. What I want: What I get: What is the Problem? And how can I fix it? Here is the SSCCE:

Arrays.sort and Arrays.parallelSort behavior of the function

I have the following code , import java.util.Arrays; public class ParellelStream { public static void main(String args[]){ Double dbl[] = new Double[1000000]; for(int i=0; i<dbl.length;i++){ dbl[i]=Math.random(); } long start = System.currentTimeMill

echo arguments for the Java program

I have a simple java program which counts arguments passed into it: public class SubsetTest { public static void main(String[] args) { System.out.println(args.length); } } However in a bash shell I try to run the program as follows: % echo A B C D |

Java: How to create a loop that creates arrays?

I need a large series of arrays, right now I am creating them manually: int[] row1 = new int[3]; int[] row2 = new int[3]; int[] row3 = new int[3]; I would like to create these in an array, something like this: public final int SIZE = 3; for (int i =

Generic table creation and null pointer errors

I have an array of linked list which runs parrallel to an ordered object array. If an extra element is entered into the object array i need to insert an extra element into the same space in the linked list. I have this method as follows public static

Is it possible to make this Java code much more efficient?

The code below is taking 27 seconds to load 51 images each image is about 22 KB (timed between the starting and ending alerts I inserted). Is it possible to make it a lot more efficient (I would like to get it to under 3 seconds)? At first I thought

java.lang.NullPointerException when I try to persist

I'm coding an application in mave,jsf ,spring ,jpa/hibernate , when I try to access a "user" jsp page mapped to the " UserManagedBean" I get an exception: GRAVE: java.lang.NullPointerException javax.faces.el.EvaluationException: java.l

How to compare three Boolean values

Compare three boolean values and display the first one that is true. Hey guys, I am trying to write a program that compares three boolean values and displays the first true one. I am comparing three words for their length, and it will display the lon

Android: SharedPreferences How to implement them correctly

I'm trying to store a user entry into an EditText field however when I exit the application it does not appear. So for example a user types in his/her name and then exits the application. When the user returns and launches the Application the users n

Is there a Java EE JDK

I know this has been asked a million times and I did do my homework, but the one last thing I don't fully understand is, is there a "Java EE JDK" ? When I download the SDK, it tries to install lots of crap I don't want. So I did some reading and

How to deploy a web application

I have created a dynamic web projects in eclipse which includes jsp pages and servlet.The back end of this application is Mysql and i include mysql-connector-java-5.1.15-bin.jar in the lib folder. I want to deploy this web application using Tomcat se

Find the cause of pending / idle threads

I noticed that my java application (runs on tomcat6) spawns a lot of threads which do not terminate. So I created a thread dump and noticed that there are tons of threads waiting, like this: "pool-1-thread-22" prio=5 tid=101b4b000 nid=0x12712200

Defining a string in a body of httpResponse

I need one help in my current development one of the requirement says: The server will return 200-OK as a response(httpresponse). If the panelist is verified then as a result, the server must also return the panelist id of this panelist. The server w

Threads and event management in Java

I am a Java newbie and an Android newbie too. I am working on a game and trying to understand the exact nature of events in Java and Android. I have a few questions to help understand the correct way to do event handling in my app. Its a network game

Super CSV (Java) - Read files with spaces in column names

I'm working with Super CSV and it looks like an amazing package. My only worry is how to work with columns with spaces in their names. No, I cannot go back and remove the spaces myself. These files will be given to me by the hundreds and I don't have

Java competition - Should block or yield?

I have multiple threads each one with its own private concurrent queue and all they do is run an infinite loop retrieving messages from it. It could happen that one of the queues doesn't receive messages for a period of time (maybe a couple seconds),

Java parses many instances of the substring of the string

I am trying to write a small java program that will accept a file (using Scanner class), return the file as a String, and then search that string for any instance of a substring starting with "Email:" and ending with ".edu". There will

PNG transparency without alpha channel

I am trying to create a transparent PNG image from a BufferedImage in Java. The PNG will be loaded into another piece of the software, that does not support the alpha channel. That should be fine, because, according to Chapter 8, section 5, part 4 of