java

How to change icon of a JLabel?

I have a jlabel to show a generated image. But it only works the first time. After that, imageicon of the jlabel does not change. What could be the problem? ...

Why is my Polymorphic Parent class calling the Subclass Method from within itself?

Heres the code I've made up so far. Its fully functional and the only gripe I have with it is that my output for Weekly and Annual pay is always weekly...I'm at a loss as to how to get this from within either toString method. public class PolyEmployees { public static void main(String[] args) { Employee [] myEmployees = { ...

Setting the from name in a javax.mail.MimeMessage?

Currently, our application uses a javax.mail to send email, using javax.mail.MailMessage. We set the From headers of the email this way: Message msg = new MimeMessage(mailSession); msg.setFrom(new InternetAddress("[email protected]")); This works just fine, but we'd like to make the "From" section a little more user-friendly. Curren...

Way to place a bad request in a dead-letter queue when using JAX-RPC?

I'm using JAX-RPC 1.1 to generate services for a set of applications running on WAS 6.0, communicating via Websphere MQ. A mainframe will be sending messages to the services, so if for some reason the message can't be converted to objects (likely due to EBCDIC-to-ASCII weirdness), the message needs to be placed on the dead-letter queue ...

Java Algorithm for finding the largest set of independent nodes in a binary tree

By independent nodes, I mean that the returned set can not contain nodes that are in immediate relations, parent and child cannot both be included. I tried to use Google, with no success. I don't think I have the right search words. A link, any help would be very much appreciated. Just started on this now. I need to return the actual...

Other usage of the this keyword in Java

(For those who read my previous question, this is the same teacher and the same project.) My teacher 'inspected' my code for a web application project and provided some suggestions. One of the suggestions was to use the this keyword even in this situation: private String getUsername() { return username; } So if I follow his advic...

Tomcat on Linux (centos). Incorrect java version.

I have installed Tomcat5 on CentOS 5 using the yum configuration tool. My java web application requires java 1.6 to run without errors. However, my tomcat install appears to be using java 1.4. This is confirmed when I navigate to the tomcat manager page: Tomcat Version JVM Version Apache Tomcat/5.5.23 1.4.2 At the linux prompt...

Text Classification in Java

Hi, I need some sort of solution in Java for the following requirements: Search in a text for certain terms (each term can be 1-3 words). For example: {"hello world", "hello"}. The match need to be exact. There are about 500 types of terms groups each contains about 30 terms. Each text might contain up to 4000 words. performance is ...

Android FTP Library

I'm looking for a java library library that works on the android that can download and resume files from an FTP server. Does anyone know of such a library. I've found lots of client apps, but no stand alone libraries. ...

How to check for COMMAND key held down Java/SWT at startup on Mac OS X

My app is cross-platform, hence why SWT is being used. I can easily monitor for the Mac Command/Flower key press when the app is running using SWT (they have SWT.COMMAND as a key press). I want to know how to see if the command key is being pressed and held down as the app opens. I found a few examples on here, but those were for caps ...

How does Spring maintain singletons,prototypes... under the hood?

I've been using Spring for a while now but I really don't know how when I ask Spring to inject a DAO in multiple different service class that it is always the same class or if I require prototype is a new one every time and so on for session scope etc. Can anyone share some light on such especially 'Singletons' as it is the most often us...

Compilation error while compiling class within another

I have two classes Hello1 and Hello, and I'm calling class Hello1 constructor within Hello class, but when I trying to compile the Hello class with command javac Hello.java I'm getting compile time error: Hello.java:6:cannot find the symbol symbol: class Hello1 location: class Hello Hello1=new Hello(); ^ Hello.java:6:cannot find the ...

Java: Generalization possible between: streams, readers, char buffers, stringbuilder, ...?

Hello everyone! Background story: There are these Source and Result interfaces for XML. These are adapters between different XML technologies in Java. Instances of these classes represent DOM, SAX, JAXB, XML streams, XML events (and even more?). The question: So, is there something comparable for plain old strings? Some generalizatio...

System.nanotime running slow?

One of my friends showed me something he had done, and I was at a serious loss to explain how this could have happened: he was using a System.nanotime to time something, and it gave the user an update every second to tell how much time had elapsed (it Thread.sleep(1000) for that part), and it took seemingly forever (something that was wa...

How to free memory in Java?

Is there a way to free memory in Java, similar to C's free() function? Or is setting the object to null and relying on GC the only option? ...

How do I detect the OpenJDK in my applet (System Properties)?

How can I determine if my client is running OpenJDK with a web plugin? I've tried java.version and the rest of the properties listed here. Running java -version from the terminal works fine, but if I went this route, java would have to be on the user's path, which I don't know if I can trust entirely. Is there any other way to see the s...

Finding the restore bounds of a JFrame when it is in a maximized state

When a JFrame is in a maximized state, the getBounds method returns bounds that match its current state. What I need is the "restore bounds" (that is, the size/location of what the window would be set to if a user clicked on "Restore Down" on a Windows platform) without actually setting it to a non-maximized state. The reason I ask is b...

How to detect if two text files are identical in java

I would like to detect if file1.xml is different than file1.xmlCheck is there a way to do this in java? I am planning on having a guid as the only difference in the files. ...

Hibernate Subquery Question

This should be a simple one I hope. I have an invoice and that invoice has a list of payments. Using the Criteria API I am trying to return a list of invoices and their payment total. So, in SQL I want something like this: SELECT i.*, (SELECT SUM(PMT_AMOUNT) FROM INVOICE_PAYMENTS p WHERE p.INVOICE = i.INVOICE) FROM INVOICES i I can'...

Is there a way to get a list of all the variables declared in a java method?

Is there a way to programatically access the variables defined inside a method ( any method, static or not ) ? How are the IDE's showing them when you debug code ? ...