java

Is xfire client proxy thread safe?

When developing an application which consumes an external webservice I have generated the sources from the wsdl-url and then created a client: GeoIPServiceClient service = new GeoIPServiceClient(); GeoIPServiceSoap geoIPClient = service.getGeoIPServiceSoap(); Since the creation of this proxy takes some time I set the client as an at...

Dynamic bytecode instrumentation - issue

I have a problem I am not able to solve. Let's assume we have the following two classes and an inheritance relationship: public class A { } public class B extends A { public void foo() {} } I want to instrument additional code such that it looks as follows: public class A { public void print() { } } public class B extends A...

In Java, how can I include dynamic version information in a log file?

From a Java application I can log a string, using a custom logging framework, as follows: logger.info("Version 1.2 of the application is currently running"); Therefore when a user sends me a log file I can easily see what version of the application they are running. The problem with the code above is that the version is hardcoded in ...

Red5 application profiling (Eclipse)

I'm using Red5Plugin for Eclipse to develop Red5 applications. This plugin creates a predefined server environment to run and debug Red5 applications from Eclipse with "a single click". Run and debug work fine. I also have Test & Performance Tools Platform installed. But when I choose the server instance in Server tab, Profile option i...

Java 5 Concurrency book recommendations

Which book or books would you recommend for learning the ins and outs of Java 5's Concurrency and most importantly why? What I'm looking for exactly is a book which especially goes through the Java 5's new concurrency mechanisms (i.e. java.util.concurrent package) and could also be used to learn most of what there is to learn about conc...

Junit4 and TestNG in one project with Maven

To run them together there are few options available but I have chosen using different profiles for Junit and TestNG. But now problem is with excluding and including test cases. Since if we add testNG dependency to main project in maven it will skip all Junit,I have decided to put it in separate profile. So I am excluding TestNG tests ...

Is it possible in java to check has-a relationship?

In java we can use instanceOf keyword to check the isA relationship. But is it possible to check hasA relationship too? ...

How to run a JAR file

I created a JAR file like this: jar cf Predit.jar *.* I ran this JAR file by doubling clicking (it does not work). So I ran it from the DOS prompt like this: java -jar Predit.jar It raised "Fail to load main class" exceptions. So I extracted this JAR file: jar -xf Predit.jar and I ran the class file: java Predit It worked wel...

Why does an hour get added on to java.util.Date for dates before Nov 1 1971?

The following code appears to demonstrate a bug in java.util.Date whereby an hour gets added on if the local clock is set to GMT with DST adjustment on and the time is before Nov 1 1971. My first assumption is always that I've got it wrong. Can anyone see what's wrong (or is this really a Java bug)? What's significant about Nov 1 1971? ...

How to Make JDBC Driver Work in Java 5 & 6?

Java 6 comes with JDBC 4, which is not backward compatible with JDBC shipped with previous versions of Java. We have a JDBC driver which must support both Java 5 and Java 6. If I implement the new interfaces in the driver, it doesn't work in Java 5 because the interfaces also uses new classes. So we have 2 versions of the driver. Is the...

Distributed systems, best framework ?

Hello, I am building a software program that follows the scenario: I have many computers, and add each one of them to the a cluster. Each computer in the cluster can add a file to a distributed table (dictionary,hashmap, should be fast enough). So now I have a place where everyone can see what files does the group/cluster contains. No...

How can I create the hash of a webpage in java?

I need to create the hash of a the html of a webpage (from its URL) using SHA1 or MD5 in java, but I don't know how to do it... can you help me? ...

How / when to delete a file in java?

The problem is, user clicks a button in JSP, which will export the displayed data. So what i am doing is, creating a temp. file and writing the contents in it [ resultSet >> xml >> csv ], and then writing the contents to ServletResponse. After closing the respons output stream, i try to delete the file, but every time it returns false. ...

md5 hash for password string in GWT/GWT-Ext?

Hi everyone, I am currently trying to modify an existing GWT-Ext application, that is using plain text passwords in its MySql database. My plan was to use md5 hashes, as the existing passwords can be easily altered with the MySql function and I was expecting to find an easy solution for the GWT-Ext side as well. But as I found out, jav...

Is it possible to 'see' the object graph for garbage collection?

I have a Java application that is leaking memory. I know which objects are not being freed during garbage collection, but I can't work out what is referencing them. Is it at all possible to have some sort of visibility of the object graph that is being held internally by the JVM? It is at all otherwise possible to find out which object...

Unresponsive thread in Tomcat

Env: Tomcat 5.x on Java 1.5.x on Windows using OracleJDBC driver on Oracle 9i The problem: I have a thread which is in RUNNABLE state. It doesn't seem to complete -ever. How do I investigate this further ? This is reproducible quite easily. This thread is basically trying to insert some data Update: This insert is happening in a syn...

Stopwatch class for Java

Which Java class should you use for time performance measurements? (One could use any date/time class, but the reason I'm asking is in .Net there's a designated Stopwatch class for this purpose) ...

Preventing SQL injection without prepared statements (JDBC)

I have a database log appender that inserts a variable number of log lines into the database every once in a while. I'd like to create an SQL statement in a way that prevents SQL injection, but not using server-side prepared statements (because I have a variable number of rows in every select, caching them won't help but might hurt perf...

Creating new mail (default client) from Java/Windows

I want to open the "new mail" view using the default mail client (i.e. open a new mail form in Outlook). But when I go String cmd = "explorer.exe \"mailto:[email protected]?subject="+ subject+"&body="+body+"\""; Runtime.getRuntime().exec(cmd); the mail shows up, but I have a problem: explorer.exe brings up an Internet Explorer inst...

Query ARP cache to get MAC ID

Hi All I need to get the MAC ID of a host in my network. For that, if I ping to that IP and query the ARP cache arp -a, I am able to get the MAC ID. I just wonder if I can get any API to query the ARP and get the MAC id. Also, if there is a better method to get the MAC ID from IP address, please suggest. P.S: I am working in JAVA. Th...