java

How can I report progress from a background task?

I have a long running task that is executing in the background on an ExecutorService thread pool. What are some best practices in terms of this task returning progress or intermediate results? Are there any libraries that provide this functionality? EDIT: To clarify, I'm talking about reporting progress to other code, not to the user....

com.jcraft.jsch.JSchException: UnknownHostKey

I don't know how SSH works and I think that's a simple question. How do I fix that exception: com.jcraft.jsch.JSchException: UnknownHostKey: mywebsite.com. RSA key fingerprint is 22:fb:ee:fe:18:cd:aa:9a:9c:78:89:9f:b4:78:75:b4 I know I should verify that key or something, but there is like zero documentation for Jsch. Here is my code...

Intercepting clicks from subview in Android

My application has a custom view which contains other custom views of a different type. The subviews have their own click listeners (which I can't change, as these are in 3rd party libraries). How can I intercept a user's click at the level of my view to do some processing, and then pass the click on to the proper subview? ...

Find total hours between two Dates

I have two Date objects and I need to get the time difference so I can determine the total hours between them. They happen to be from the same day. The result I would like would have the hours and minutes. When I use .toString() on my Date object I get this: Fri Dec 18 08:08:10 CST 2009 I've tried the following: long diff=(this.en...

Java Media Framework: extract audio info from mp3 file

Hi, I'm analyzing music mp3 files. What I'm doing is extracting the audio data from the file and computing music similarity. I've been using javazoom in order to handle mp3 files. By using audioFormat I'm extracting the raw data from the mp3 file: byte[] audioBytes = new byte[numBytes]; in_format_init = AudioSystem.getAudioInputStream...

Has Java ever been used in outer space?

In response to a question about examples of Java usages, I bumped across some articles where NASA used Java for ground control in a mission to Mars but I couldn't find out if it has ever been used outside of Earth. Do you know of any such instances? ...

Pros and cons of writing complete view logic of a web application in a javascript library (ExtJS) ?

I am a newbie in web development using javascript libraries. But I recently saw a J2EE web application that uses ExtJS extensively (say 90%) for rendering the web pages. The web pages in question are either simple forms or grids (tabular reports). The JSPs are fairly threadbare and simply delegate to the ExtJS framework (using onReady fu...

Learn different Java technologies without GUIs?

Hi, I'm pretty much a beginner at programming and I know only basics of VB, Java, and C++ as well. Lately, I was trying to work on my Java by building some very simple desktop apps but I found swing and layout managers to be very frustrating. I know how to make them work and I've done them before (not saying I'm good at them) but doing ...

java api to send file through serial port

Hi geeks, I want to send a file from my PC to a remote device connected through serial port. So is there any API in java to send file over serial port? ...

Lightweight microbenchmark library with graph output (Java)

Is there a good Java library for taking the legwork out of writing good micro-benchmarks? I'm thinking something which can provide (with a minimum of hassle) provide text (CSV or HTML, take your pick) output of results and maybe graphs summarizing results. Ideally, it should be something that plays nicely with JUnit or equivalent, and ...

Mibble MIB Parser - extracting comments from the mib.

I am using the Mibble MIB Parser to extract all simple data types from an MIB file. I've been successful until my attempt to extract comment text. Take the following module as an example: invBookList OBJECT-TYPE SYNTAX INTEGER { mobydick(1), -- call me ishmael paradiselost(2), -- aComm...

Java ME - is the Bluetooth address ID globally unique?

I'm coding a Java ME app and attempting to globally identify each phone using the app. The first attempt is to load the IMEI per this question. As a fallback ID I'm using the bluetooth address of the device. Is the bluetooth address of a cellphone a globally unique identifier? Is it a MAC address? Some other format? ...

obfuscating java web applications

From what I understand, obfuscating a java web application will just make it a little harder to read your application, but reverse engineering is still possible. My goal is just to make it very difficult to read, and not be able to decompile and run (not sure if that's possible, I guess it will still run just with ugly variable names??...

Alternatives to Bouncy Castle java library for PKCS7 encryption/signing?

We've always used the BouncyCastle library, I'm being asked if there are other viable alternatives, either open source or not. Or is the BouncyCastle library already the best one to use? ...

ANT: How to "add" path elements from one path into a second path ?

I have an ANT build xml file which includes a path declaration with numerous path elements. I would like to declare a second path that "includes" somehow all the elements from the former path into its own. That would then allow me to just the later path rather than requiring me to include both when paths are required. Without copying al...

java web UI testing tool, something that converts DOM to objects?

is there a java UI testing tool (web) that converts the DOM into a java object of sort? So I can do something like: browser.GoToPage("google").FindButton("search").click(); ...

Java Coloring a Table row

I want to color a Table row depending on whether there is a non-null in its 3rd column. Heres the code that I wrote : (ignore the braces) public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { JComponent c =(JComponent) super.prepareRenderer(renderer, row, column); c.setBorder(BorderFactory....

Useful Java Coding Tools

I was wondering what kind of tools people use to make their coding experience more enjoyable or easy. Especially in java. Also, what kind of tools would be nice? EDIT: Let's assume we all use some IDE that supports plugins... :-p ...

AVL Tree Balancing

Hello, I am working on an assignment that asks me to implement an AVL tree. I'm pretty sure I have the rotation methods correct, but I'm having trouble figuring out when to use them. For example, the explanation in the book says that I should climb up the same path I went down to insert the node/element. However, I can't have any parent...

How to capture video from webcam(in java)?

I want to develop an application in java to capture video from webcam and store it onto a particular location.Can anyone provide me the working code? What type(usb,ip etc..) of webcam is the best in order to develop the application. Please help me. how to proceed? ...