java

Algorithm choices - understanding which and why

I am writing a document and was unsure of the following: I am going to compare two algorithms that can perform on the same structure but we cant say one will always be faster than the other (and I will define circumstances in which a is better than b and vice versa); for this I was going to use quicksort and bubblesort. Is this a good ...

Whats the work of JDK and JRE?

Hi, I have a confusion that what JRE is doin on the Background and what does the JDK doing. ...

private javax.swing.JTextField3; error

I greatly thanks those that reply to my question "main method not found error", after correcting all the parenthesis and it seem the code is alright.On the IDE its still indicate the error below; private javax.swing.JButton jButton1; private javax.swing.JComboBox jComboBox1; private javax.swing.JLa...

How to make the main thread wait for the other threads to complete in ThreadPoolExecutor

Hi, I am using the ThreadPoolExecutor to implement threading in my Java Application. I have a XML which I need to parse and add each node of it to a thread to execute the completion. My implementation is like this: parse_tp is a threadpool object created & ParseQuotesXML is the class with the run method. try { ...

thread reaches end but isn't removed

I create a bunch of threads to do some processing: new Thread("upd-" + id){ @Override public void run(){ try{ doSomething(); } catch (Throwable e){ LOG.error("error", e); } finally{ LOG.debug("thread death"); } } }.start(); I know i should be using a threadPool but i need to ...

import com.sun.image.codec.jpeg.*

i have a java program when i compile it i get the following error [javac] ...\MyClass.java:33: package com.sun.image.codec.jpeg does not exist [javac] import com.sun.image.codec.jpeg.*; [javac] ^ what can i do ? What is the correct way of writing an image file now that the com.sun package is deprecated. ...

Running out of java heap space- 15 puzzle problem.

G'day all, I tried the solution for eight puzzle problem posted here by joel Neely and played around with it and modified it so that can be used to solve for higher grids[Changed the String representation of the grid to two dimensional integer representation and modified the logic accordingly]. However the modified code can solve th...

<? super E> and <? extends E> for List

Having the following simple class structure: class A{} class B extends A{} class C extends B{} I'm creating an ArrayList to keep objects of the earlier created classes: List<? extends A> list1 = new ArrayList<A>(); List<? extends B> list2 = new ArrayList<B>(); List<? extends C> list3 = new ArrayList<C>(); List<? super A> list...

How do you turn on a hibernate filter for a particular entity by default?

Good day, I currently have an Entity that has a where clause set on it. I want to put that where clause on a filter and have that turned-on by default (so that I won't break any existing functionalities). I want to turn it into a filter so that I can disable it because I have a use case wherein I need it disabled. How can I do that in...

intranet chat application using java

Any help would be great please..! How to build an intranet chat application using java which includes transform of files like gtalk? where to start the process? what all the sw requirements? ...

Does this applet work for you?

Hello all, I have found a solution to get the full file path of a file that is about to be uploaded using a Java Applet. I need this for an internal system not anything else "dodgy"! Can anyone confirm if this works in an IE6 browser: http://www.maschek.hu/preview/ffx3%5Ffile/filepath.html I have an IETester application that has IE6/7...

Tomcat - UnsupportedClassException

Hi, I have a problem deploying compiled classes in a Tomcat web application: I'm deploying a class which is to be called from a servlet, but when I run the application it fails telling me of a ServletException: Error allocating the servlet instance due to an UnsupportedClassVersionError: Bad version number in .class file. Tomcat is usin...

LinkedIn integration - Establish a requestToken

Hi. I'm developing (trying for now) portlet that will be integrated with LinkedIn. Following the documentation about it: http://developer.linkedin.com/docs/DOC-1008 --> The first step to authorizing a LinkedIn member is requesting a requestToken. This request is done with an HTTP POST. For the requestToken step, the following componen...

loop's counter i as I++ vs. i+1 as position in an array

I've made a loop with i as it's counter variable. Inside that loop I'm comparing cells of an array. I'm wondering what's the difference between array[i++] (or array[++i]) to array[i+1]. Since i++ (or ++i) don't work in the wanted way while i+1 does (a little bag which drove me crazy). Thanks in advance. ...

Speed up expand/collapse all nodes of a JTree

Hi! I have a JTree with about 100000 nodes or more. Now I want to expand the whole tree. To do so I use the solution I found here. My problem is that expanding such a large tree takes like 60 seconds or more, which is not very convenient. Does anyone have any suggestions how I could speed up expansion? Thanks in advance... ...

cancel read operation

DataInputStream in; byte[] b = new byte[1024]; for (;;){ in.read(b); //do something } I have the above code. In another thread i am handling some other events. In this thread i want to cancel the read operation shown in the above code. How can i do? ...

how can I set an image in to seventh column?

hi, I have a sql table which has 7 column and the first six column ,store string type but the last one store BLOB type.I get those 6 String types with the addBirth method and for storing the image for last column ,I use insertImageToBirthTable method. I want to store Strings and BLOB not together because the user may not chose a photo fo...

Java Getters and Setters

Is there a better standard way to create getters and setters in Java? It is quite verbose to have to explicitly define getters and setters for each variable. Is there a better standard annotations approach? Does Spring have something like this? Even C# has properties. ...

Java - boolean primitive type - size

The Java Virtual Machine Specification says that there is limited support for boolean primitive types. There are no Java virtual machine instructions solely dedicated to operations on boolean values. Instead, expressions in the Java programming language that operate on boolean values are compiled to use values of the Java virtual mac...

Java: Turkish Encoding Mac/Windows

Hi I have a problem with turkish special characters on different machines. The following code: String turkish = "ğüşçĞÜŞÇı"; String test1 = new String(turkish.getBytes()); String test2 = new String(turkish.getBytes("UTF-8")); String test3 = new String(turkish.getBytes("UTF-8"), "UTF-8"); System.out.println(test1); System.out.println(...