java

JAVA: how to call a method when the process has been stopped (is it even possible?)

Hi all, I want it so when my users start my program from the command line and then kill the process (ctrl+c, for example) the program will shutdown gracefully by closing all its connections. Is this even possible? I can't just have it call a method upon closing like a GUI can? This program has no GUI. Please let me know. Thanks, jb...

Storing search criteria in a database

I am working on an enhancement to a Flex dashboard that will allow the users to save searches. I'm using BlazeDS and Java/Spring/SpringJdbc on the server side. My question is this: how would you model a search that has one or more criteria, such as: Value Date between 2009-10-01 and 2009-10-31 Currency = 'USD' Bank Name starts with ...

Get System Information of a Remote Machine (Using Java)

As the question's title says, I want to get the system information (like OS name, version, etc.) of a remote system using Java. But before anyone answers this question, I just want to ask whether this is possible, if yes, then how? One more catch is that this should work for both Unix-based and Windows-based systems. I tried searching t...

Java Synchronized and Threads

I'm having issues with Synchronized not behaving the way i expect, i tried using volatile keyword also: Shared Object: public class ThreadValue { private String caller; private String value; public ThreadValue( String caller, String value ) { this.value = value; this.caller = caller; } public sync...

java synchronized issue

I'm having issues with Synchronized not behaving the way i expect, i tried using volatile keyword also: Shared Object: public class ThreadValue { private String caller; private String value; public ThreadValue( String caller, String value ) { this.value = value; this.caller = caller; } public synchronized String getValue() { ...

Can I detect when the Garbage collector works?

Am working on a swing app. I will experiance slowness after continuous half an hour of use. can it because of GC running? How can i find when the garbage collector runs through any jdk 1.5 commandline option? Thanks ...

JSP Page HttpServletRequest getAttribute Typecasting

Hi There, Any ideas on the correct method of typecasting an Object out of a getAttribute request from a JSP page HttpServletRequest? I have googled but it seems that the common solution is just sticking suppresswarnings in your code... Something I would very much like to avoid. I currently have: HashMap<String, ArrayList<HashMap<Stri...

Storing long strings (CLOB) in Hsqldb databases?

So here's some code: statement.executeUpdate("CREATE TABLE SomeTable(id INTEGER IDENTITY, " + "text CLOB)"); which throws an exception "Wrong data type: CLOB in statement [...]". Is there a way to store CLOBs in Hsqldb databases? The documentation says it is. Or maybe my knowledge of SQL is so rusty that I forgot how to define the...

event attached with button clicking

I have a JFrame in which there are 2 textfields and 1 JButton. Users need to enter some string in the textbox. When user clicks the button in the JFrame then these strings get displayed in a JTable. I am not getting what code shall i write with button clicking. Please help me. Thanks. ...

How do I receive SNMP traps on OS X?

I need to receive and parse some SNMP traps (messages) and I would appreciate any advice on getting the code I have working on my OS X machine. I have been given some Java code that runs on Windows with net-snmp. I'd like to either get the Java code running on my development machine or whip up some Python code to do the same. I was able...

How do I package multiple WAR files in one Maven project?

I am writing an application that integrates Geoserver with a custom component, intended to be hosted on a single servlet engine. Both are Maven based projects, and I would like to stay in Maven land to package it all into a nice distributable. The general idea I have is to add another module to my application that packages the applicatio...

Can one automaticaly create javadoc tags for an entire Eclipse project?

I know one can use '<alt><shift>J' to create tags for a single code element (class method for example). But is there a way to automaticaly create these tags for every class in the entire project? Or even just at package or class level? ...

Is there a way to determine Java version without seeing shell output?

I have a following problem. I am executing an OS command line from within Oracle database that executes an external jar file with some parameters. I can't see shell output but I can connect with a different user to that same server through ssh/ftp and read files. There are multiple versions of Java on that server and I would like to see...

Retrieving the logged in user's name and hostname in Windows

I'm currently writing a Java application to be used with a Windows-Machine authed with an ActiveDirectory. The application basically only needs to know the user's name and hostname. I know there are System.getProperty("user.name") and java.net.InetAddress.getLocalHost().getHostName() But I am not sure wether System.getProperty("user....

Access JBOSS Tomcat Web Application from Remote Computer

Hi, I just deployed a web application on JBOSS 4.2. It can be accessed locally only (http://localhost:8080/myApp). I cant access it from remote computer by typing its domain: (www.hostname.com:8080/myApp). I added Port 8080 as Exception in Windows Firewall. Note that the host (www.hostname.com) is reachable from remote computers via IIS...

Insert Java Object In Sql Server

Hi! How Can I Insert/Retrive A Java Object Into/From Sql Server? THX ...

sun.font.TrueTypeFont Memory Leak?

I've been profiling some Java software using heap dumps and there is 350 instances of sun.font.TrueTypeFont, in other heap dumps I have taken there have been more. There is only 5 instances of Font created by the app code, and 24 instances in all, mostly created by WDesktopProperties and other Java library classes. Is this number of Tr...

Can annotations be used for code injection?

Hi all, I realise that this might be a question that has been asked and answered, but please bear with me. I want to know if it is possible to use annotations to inject code into your classes compile time. The classic example is to generate a getter and setter for the members of your object. This is not exactly what I need it for, but ...

What is the native way of implementing Publish Subscribe between Android widgets ?

I have a custom EditText and a TextView in an Activity. The custom EditText traps for key presses and calculates the number of character entered and wants to publish the character count to the TextView. Do I use the java.util.Observable/Observer way ? Or is there a more native android method to achive this ? Thanks. ...

How can I suppress java compiler warnings about Sun proprietary API

I'm using the encode() method from the sun.misc.BASE64Encoder package. How do I suppress the compiler warnings that it generates? sun.misc.BASE64Encoder is Sun proprietary API and may be removed in And as a followup, why don't I see this warning in Eclipse? ...