java

Enumerating USB Devices on Windows with Java

In a previous SO question, it was mentioned that USB devices can be mounted using the following approach in Windows: MOUNTVOL C:\USB: \\?\Volume{ebc79032-5270-11d8-a724-806d6172696f}\ My question is what is that String starting with \\?\Volume called, and what is the best way to retrieve that. I would rather not use .NET if possible si...

Java swing UI crash debugging

I am trying to debug a problem where a user clicks on the button and the UI just dies. I know, good luck. The logs just end after the user clicks the button so i'm thinking there may be some exception/error that we are not logging. Maybe an OutOfMemoryError. Any suggestions on how to proceed? to get more information. Java command ...

How can I get an Input Stream from HSSFWorkbook Object

I want my web application users to download some data as an Excel file. I have the next function to send an Input Stream in the response object. public static void sendFile(InputStream is, HttpServletResponse response) throws IOException { BufferedInputStream in = null; try { int count; byte[] buffer = new byte...

How to invoke groovy with 'java' from command line

I have to ship some groovy code to some users that have only java installed (no grooy, no $groovy_home, etc). I'm trying to invoke groovy from the commandline but I'm having no luck. Here's my bat file: java -classpath .;lib;bin;bin-groovy introspector.AclCollector And here's my exception: Exception in thread "main" java.lang.NoClass...

Does the JSF convertNumber with currency format round or truncate additional decimal places?

Here is an example: <h:outputText value="#{myBean.myMoney}"> <f:convertNumber type="currency" currencySymbol="$" /> </h:outputText> Given that I have $1.006, will this output $1.00 or $1.01? Doesn't say here: http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/f/convertNumber.html ...

Format Double as Fraction

Is there a library that will convert a Double to a String with the whole number, followed by a fraction? For example 1.125 = 1 1/8 I am only looking for fractions to a 64th of an inch. ...

Java I/O using inpout32.dll

I am trying to control some LEDs wired to the parallel port on Windows XP. The easiest solution would be Inpout32.dll from Logix4u.net. I have found many source code samples in various languages (C++, Visual Basic, C#) but nothing using Java. Do you know any tutorials about calling DLL functions from Java ? (what I have found so far on ...

Java GUI repainting problem?

This one's a tough one - I have a JFrame that generates JTextFields. When I go from generating 2 JTextFields to 12 JTextfields (for example), I see some error where there is an extra differently-sized JTextField at the end. It seems to be a repaint error. Main.java code: import java.awt.; import javax.swing.; public class Main ...

What would you use to build a web app?

At my current job I've been working on making web apps with Java, Tapestry, Hibernate, MSSQL, and Tomcat. I've got an idea for a little web game I'd like to write. I'd like to know what the SO community would use for something like this. Should I stick to what I know? I was thinking it would be very beneficial for me to learn different...

Java: split a List into two sub-Lists?

What's the simplest, most standard, and/or most efficient way to split a List into two sub-Lists in Java? It's OK to mutate the original List, so no copying should be necessary. The method signature could be /** Split a list into two sublists. The original list will be modified to * have size i and will contain exactly the same element...

possible java JNA issue

my java UI unexpectly terminated and dumped a hs_err_pid file. The file says "The crash happened outside the Java Virtual Machine in native code." So JNA is the only native code we use. Does anyone know of any know issues or bugs with any JNA version that might cause this. I've included some of the contents from the error file below. ...

Why I cannot cast oracle BLOB from native java Blob

I am reading file from ResultSet and it's required to save file into Oracle Database. ... ResultSet rs = ... java.sql.Blob myfile = rs.getBlob("field") java.io.OutputStream os = ((oracle.sql.BLOB) myfile).getBinaryOutputStream(); I get get this error message java.lang.ClassCastException Any one have solution to this? Thanks! ...

Getting ENTER to work with a JSpinner the way it does with a JTextField

First, to make my job explaining a bit easier, here's some of my code: JSpinner spin = new JSpinner( ); JFormattedTextField text = getTextField( spin ); text.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed( java.awt.event.ActionEvent evt ) { // Do stuff... } ...

How can I best apply OOP principles to games and other input-driven GUI apps?

Whenever I try to write graphical programs (whether a game or really any GUI app) I always wind up with one or two god classes with way too many methods (and long methods, too), and each class having far too many responsibilities. I have graphics being done at the same time as calculations and logic, and I feel like this is a really bad ...

Trustworthy developers writing about both Java and .NET?

Let me first of all say that I'm NOT interested in a flame war about what is better: .NET or Java... PLEASE don't post if you want to tell me how killer .NET is or how Microsoft is the evil empire so there is no way that a developer with a soul could write .NET or whatever. We've all heard it far too much before. What I'm interested is ...

Simple Java MIDI example not producing any sound

This simple code is not producing any sound on a couple of machines that I've used to test it. I'm running the code from within Eclipse, but I've also tried using the command line to no avail. public static void main(String[] args) { try { Synthesizer synthesizer = MidiSystem.getSynthesizer(); synthesizer.open(); ...

Mercurial API for Java?

Is there a plain API to access Mercurial repositories from Java? There are plugins for Netbeans and Eclipse, but unlike their Subversion counterparts, they do not use a common lower-level library but bring their own wrappers to call out to the Mercurial binary. Calling the binary would be okay (for now), but it seems very difficult to u...

Java inner class .class file names

If I have an inner class, like this: public class Test { public class Inner { // code ... } public static void main(String[] args) { // code ... } } When I compile it, I expect it should generate two files: Test.class Test$Inner.class So why do I sometimes see classfiles like SomeClass$1.class, ev...

Difference between classpath and endorsed directory

Does anyone know what the difference is between adding an appropriate JAR-file (eg. Apache XALAN) to a JRE's endorsed directory and adding it to the application's classpath? Is it possible to take a jar-file that can be added to the endorsed lib and instead add it to the classpath? ...

Application to query a database and send results as file via HTTPS

I've currently got a tool which allows me to configure a database connection (using JDBC) and specify a set of queries to run against the database. This is scheduled to run at a specific time of day (using cron or windows scheduler currently). The tool then exports the results to a file (xml) and sends this file to my server via HTTPS. T...