java

Why does ant.bat not return an error status when run programmatically?

When I run ant from the command-line, if I get a failure, I get a non-zero exit status ($? on UNIX, %ERRORLEVEL% on Windows). But we have a Java program which is running ant (through ProcessBuilder), and when ant fails, on Windows we cannot get the exit status. I just verified this with this simple ant test file: <project name="x" def...

HttpClient 4 - how to capture last redirect URL

I have rather simple HttpClient 4 code that calls HttpGet to get HTML output. The HTML returns with scripts and image locations all set to local (e.g. <img src="/images/foo.jpg"/>) so I need calling URL to make these into absolute (<img src="http://foo.com/images/foo.jpg"/&gt;) Now comes the problem - during the call there may be one or ...

How to know when a user has really released a key in Java?

(Edited for clarity) I want to detect when a user presses and releases a key in Java Swing, ignoring the keyboard auto repeat feature. I also would like a pure Java approach the works on Linux, Mac OS and Windows. Requirements: When the user presses some key I want to know what key is that; When the user releases some key, I want to ...

Find text files in Jar

I have an app which has to read from a text file (using FileInputStream). The text file is in the directory structure relative to the class file (eg. "../textdir/text.txt"). When I run it normally (ie specifying the /bin folder containing the .class file in the cp) everything works fine. However, I somehow need to package everything into...

Java: How to convert MySQL DECIMAL(39,0) IP address to String

So I'm told that the DBAs here are going to be storing IP addresses in a DECIMAL(39,0) field in our MySQL database. How can I go about translating that into a String to pass on to our other applications? Note: Our databases can't take any more load, so as much of the work as possible needs to be done in the Java application. Note2: IP...

Is there a javadoc replacement that uses a Wiki-like syntax?

Is there a tool replacing javadoc with something that is more Wiki-style syntax instead of the HTMLish syntax of normal JavaDoc? One of my problems is that I mostly read JavaDoc in source form. Even for external libraries I try to have the source attached so I can navigate into it from my IDE, checking the documentation above the entry ...

JXL and Apache POI parsing excel with attached image objects

I have tried using JXL and Apache POI to load data from an excel file, up until now the JXL mechanism has worked fine. Even if I embed an images in the file. I received a file from a source which wont parse, I get the following exception with POI Exception in thread "main" org.apache.poi.hssf.record.RecordInputStream$LeftoverDataExcep...

How can I pass an anonymous JavaScript object from Java to JavaScript in GWT?

Hi, I'm creating a GWT wrapper round a JavaScript library. One of the JavaScript functions takes an anonymous object as its argument e.g.: obj.buildTabs({ hide: true, placeholder: 'placeholder' }); On the Java side how do I create this type of JavaScript object and pass it to my native implementation? At the moment, on the Java sid...

windows-1252 character 146 is stopping POST data reaching servlet in glassfish v2

An HTTP POST request is made to my servlet. There is a posted form parameter in the http request that my code in the servlet retrieves for further processing named "payload". When the value of the payload includes the windows-1252 character "’" (ascii value 146), HttpServletRequest instance method getParameter("payload") returns null. ...

What is the difference between NoClassDefFoundError and ClassNotFoundException ?

I want to know the difference between the specified error and the exception. What is the reason for getting each of them and any thought process on how to deal with such errors? While working on a project. If we are modifying the existing code to include the new jar file I get to face these exceptions. Sometimes they will come in clien...

Help using Facebook REST API - Notifications.send using HttpClient (Java)

Hello there, I am using the session proxy method to login to Facebook using Facebook Connect (via my iPhone simulator) and obtain my session key. Am using server side Java to send the notification, however. What I am trying to do is just send a user to user notification back to myself (that's why I set the to_uids as an empty string). I...

Compacting HTTP Response Headers?

I had asked a few questions regarding compressing HTTP Request headers here and here but I some how skipped the HTTP response part... I am looking for a way to reduce/compact the headers in my HTTP response... The situation is that I am communicating a Java ME app with a remote Server and any extra baggage is causing me to shed out load...

java: How to make defensive copy when you only have an interface

If an object takes a reference to another object, I know it can be a good idea to make a copy of the passed-in object to preserve encapsulation. But, what if all the object knows about the object passed in is that it implements an interface? For example, if I have an object that takes an implementation of FilenameFilter in its construc...

How to check memory leak?

Is it possible to check the memory leak without going into the code. I have the application with me and I want to check whether there is memory leak or not. In my present organisation, I check the cpu usage before and after running the application as well as the cpu usage of the process of the application. But I don't think this is the ...

How can I get a free easy multiplatform installer for a java program

Hi I made a java swing application. Also created jar of that file. Now I want to make that file in installable format (means in .exe format for windows bin format for linux X86 format). If we install any software we get some license agreement. I want to make my jar in that format which can be installed in any platform. So is there any f...

Graphing Data with Java Processing

I'm looking at creating a program with Processing (processing.org) in Java. The program will involve graphing a large amount of 2D data. I would like for the points to be displayed to fill the window. I've looked at their libraries and I don't see anything for data visualization. Am I missing something? ...

number of 1's in 32 bit number

I am lookin for a method to have number of 1's in 32 bit number without using a loop in between. can any body help me and provide me the code or algorithm to do so. Thanks in advance. ...

Best way to handle Facebook Error Response Codes using Server Side Java?

Hello there, Don't know if this particular forum is the best place to ask this question... What is the best way to handle error response codes generated from Facebook REST API calls using server side Java? For example, if in a deployed app, a person calls Friends.get: http://wiki.developers.facebook.com/index.php/Friends.get The fo...

Java applications with Windows 7 - are there compatibility concerns?

Hi, with some fuzz around Windows 7, does somebody have experiences with Java compatibility with Windows 7? Should this be a concern or do the programs probably work ok? I'd be especially interested if somebody has experiences with Swing applications? The versions available seem to be beta versions so they won't provide perfect basis ...

Java Graphics2D Panning and Zooming / Translating and Scaling

I've got a JPanel I'm drawing onto and I'm trying to get it so that you can use the mouse wheel to "zoom" in and out by modifying the variable scale. Right now what happens is you can zoom in or out but all of the drawing shifts to the right and downwards when you zoom in and then back up and left when zooming out. I want to make it so...