java

Reading Microsoft Access files in Java

How to read (and write) MS Access files (.mdb) in Java? Is there any open-source jdbc driver for MS Access? ...

Always get null when querying XML with XPath

I am using the following code to query some XML with XPath I get from a stream. DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(false); DocumentBuilder builder = domFactory.newDocumentBuilder(); Document doc = builder.parse(inputStream); inputStream.close(); XPathFactory factory = ...

How to convert a Swing Application to an Applet?

I created a desktop application with Swing Application Framework, now how can I convert it to an applet? The main class extends SingleFrameApplication. EDITED: This is the starting class, used NetBeans GUI builder: public class PhotoApp extends SingleFrameApplication { /** * At startup create and show the main frame of the ap...

Java Number comparisons

Is there something I can use to see if a number starts with the same digit as another? Ex. 5643 and 5377 both start with five. Is there a way to do this with numbers or do they have to be strings? (startsWith?) ...

Best Java Functor lib: JGA, commons functor, mango, or... ?

I am interested in using functors (function objects) in Java. With quick googling I found these 3 packages: Java Generics Algorithms: http://jga.sourceforge.net/ Commons functor: http://commons.apache.org/sandbox/functor/ Mango: http://www.jezuk.co.uk/cgi-bin/view/mango and of 3, JGA seemed like it might have the best design. But I s...

Can Hibernate be used in performance sensitive applications?

I'm seeing performance problems with retrieving multiple instances of objects that have many relationships with other objects. I'm using Spring and Hibernate's JPA implementation with MySQL. The issue is that when executing a JPA query, Hibernate does not automatically join to other tables. This results in n*r + 1 SQL queries, where n is...

Checking for valid credit card numbers.... lots of syntax errors.

At this point I'm fairly certain the code will run properly once I clear up all syntax errors. However I'm not really sure how to do this as I am not entirely familiar with Java. Any help is appreciated. Thanks for your help everyone I'm now using NetBeans. I'm seeing lots of errors but I'm not sure how to fix th...

Setting JAVA_HOME when running Ant from Java

The reason is long and boring, but I need to run an Ant script to compile Java 1.5 code from a Java 1.4 app. I keep getting this error, though: BUILD FAILED build.xml:16: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\j2sdk1.4.2...

Limitations on the number of BCC recipients

I have an app which is programmatically generating and sending out emails. The recipients list can get upwards of 1000. I had been looping through and sending out individual emails, but that was taking too long at about .5 sec each. The approach I'm looking into now is to remove customization in the message body and send out a single ...

Using SQL in Java with package java.sql

Hello, during a lecture my professor gave examples of several actions involving databases and the java.sql package. These examples were supposed to be uploaded online in a pdf file, but for some reason the names of all functions and class names aren't displaying with my pdf reader. I would like to know the equilavents of the following P...

How do I make Weblogic 8.1 serve static content?

I come from the Open source world where I'm used to having Apache serve up my images, css, javascript, etc., while Tomcat or an app server of its ilk handles all the JEE lifting. But now I'm doing a project with Weblogic 8.1, and I can't seem to figure out how to get it to work. For example, the concept of a document root. How can I con...

How do I convert between ISO-8859-1 and UTF-8 in Java?

Does anyone know how to convert a string from ISO-8859-1 to UTF-8 and back in Java? I'm getting a string from the web and saving it in the RMS (J2ME), but I want to preserve the special chars and get the string from the RMS but with the ISO-8859-1 encoding. How do I do this? ...

The best way to iterate SortedSet / SortedMap in Java backwards

I need to iterate through SortedMap's entry set (which is a SortedSet) backwards. The code I'm writing is extremely performance-sensitive, as it's going to be called from many places thousands times per second, maybe more. Any advice on doing it the fastest way? ...

How to Prevent an Applet from Unloading across web pages?

I have a large applet that takes some 40 seconds to initialize (cabs are cached so ignore download time for this question). The issue is, if the user goes to Page A which launches the applet (single window) and then navigates to page B, the applet is unloaded. If the user goes back to Page A, they incur the 40 seconds init time once ag...

Java equivelant of setInterval in javascript

Basically I want a function to be called every say, 10 milliseconds. How can I achieve that in Java? ...

JTable no update when selection

Hi all When I select a row in a JTable, my JTable doesn't get updated anymore. When I don't select a row, the code beneath works as expected. A row is added to the JTable. @Override public void update (Observable arg0, Object arg1) { if (arg0 instanceof Logger) { LogItem last = systemController.logController.getLog().getLastLog...

Can someone explain the ivy.xml dependency's conf attribute?

I can't find any thorough explanation of the ivy dependency tag's conf attribute: <dependency org="hibernate" name="hibernate" rev="3.1.3" conf="runtime, standalone -> runtime(*)"/> See that conf attribute? I can't find any explanation (that I can understand) about the right hand side of the -> symbol. PLEASE keep in mind I don't k...

Is there a Maven Alternative or port for the .NET world?

Is there a Maven Alternative or port for the .NET world? I would love to use a good dependency management system that the Java world has ... but i don't find anything comparable for .NET projects ... georg ...

Need Help With Arrays,Functions and Binary Search (Java)

So basically what I want to do is a program that asks the user how big he wants his array to be and for the user to introduce the values inside the array. Then I want the user to be able to introduce a number and for the program to determine in which array the number is or determine that it doesn't exist. The following program currently ...

java.sql.SQLException: No suitable driver on Mac OS X Attempting to use Derby

Hello, I am getting a java.sql.SQLException: No suitable driver when I am trying to connect to a database with Java. I am on Mac OS 10.5 using the NetBeans IDE. It seems to be having trouble with the EmbeddedDriver, but I'm not sure what I am missing: public class A { Connection conn = null; public A(String URL...