java

Tomcat on Windows server woes

Hi, Synopsis: When calling an executable that links to shared libraries from Java code on Tomcat, I get errors on Windows 2003 whereas the executable works great on a command prompt. I wanted to do this in Linux, but, alas, got outvoted and have to implement it using Windows Server 2003. Here it goes, I have a simple Java code running...

Notify a Button if the number of files in a directory change

I have a button that I want to disable as long as there isn't a specific number of files in a directory. Is there some kind of listener that notifies me at the moment a file is created or deleted in a directory? ...

Scrollbar visible

Is there some way to know if a scrollbar is visible or not inside a JPanel? I mean, some times, my panel has many rectangles (think it as buttons) and needs a scrollbar and some times it doesn't need it. I'd like to know if I can know when it is being shown. ...

Ant and XML configuration file parsing

I have an XML file of the following form - <map MAP_XML_VERSION="1.0"> <entry key="database.user" value="user1"/> ... </map> Does ant have a native ability to read this and let me perform an xquery to pull back values for keys? Going through the API I did not see such capabilities. ...

Getting system font properties in Java/Swing

I am working on a Java application using Swing and I want to set up the GUI using the "proper" fonts and font sizes. With proper I mean the fonts (+size) as defined by the user, so that my application will fit right in to the user's screen setup (resolution / font size combination) without having to provide my own custom settings. My app...

Any way to make Java honor the DNS Caching Timeout (TTL)?

We use GSLB for geo-distribution and load-balancing. Each service is assigned a fixed domain name. Through some DNS magic, the domain name is resolved into an IP that's closest to the server with least load. For the load-balancing to work, the application server needs to honor the TTL from DNS response and to resolve the domain name agai...

Java HttpServletRequest get URL in browsers URL bar.

So I'm trying to grab the current URL of the page using Java's request object. I've been using request.getRequestURI() to preform this, but I noticed that when a java class reroutes me to a different page off a servlet request getRequestURI gives that that address as opposed to the orginal URL that was typed in the browser and which stil...

How to combine repaints in Swing?

I am calling repaint a bunch of times from a listeners, but the way I designed my paint function is only one repaint is required. I generate a bunch of repaints, since it hooked into my mouse motion listener. Is there a way to cancel all pending repaints for a certain component? I can't just start ignoring repaints, since some are val...

Raw Strings in Java?

Is there any way to use raw strings in Java (without escape sequences)? (I'm writing a fair amount of regex code and raw strings would make my code immensely more readable) I understand that the language does not provide this directly, but is there any way to "simulate" them in any way whatsoever? ...

Why chose XML over properties files for Log4J configuration?

Are there any reasons to use XML over properties files for Log4J configuration? ...

Reflectively accessing a static variable in a Java class

I've been given no other choice but to access a set of classes, which I cannot modify, with this structure through reflection. Using the method shown in the main method below however, throws a NullPointerException. The null pointer being "table" in the constructor when f1.get(null) is called. I am unable to instantiate the classes befo...

Doc templates to PDF files in java (looking for tools/libs)

Hi all, I tried to read the related questions and didn't find any new tool. Here is my problem : i generate some PDF files for an insurance from the data in my app. Stuff like, contracts, certificates, bills etc. The insurance guy gives me the templates files as .docs with fields in them and I have to fill in the fields with my data a...

How to get started with Atom and Java?

I'm interested in producing feeds using Atom (the XML syndication format) and Java, but I'm not sure where to start. Can anyone recommend libraries, tutorials etc. to get started? ...

What's Python's equivalent to Java InputStream's available method?

Java's InputStream provides a method named available which returns the number of bytes that can be read without blocking. How can I achieve this in Python? ...

Get REAL X.509 data from RFC1421 formatted certificate.

We have a Java application that stores RSA public keys and allows a user to encrypt a short stream of information with any of the keys. The application also allows the user to import a new key certificate into the keystore. When we load the certificate from a file, we want to use the common name (CN) as the alias. Here is the problem: C...

Making a JOptionPane with 4 options

I need to make a custom dialog with 4 options but as far as I can tell you can only have one with three options. Here is how I would make an option pane with 3 options: Frame refFrame = DialogUtils.getReferenceFrame(); ///TODO: /// - Use DialogUtils int option = JOptionPane.showOptionDialog(refFrame, ...

Getting burned by inconsistent passed by value rules in Java (1.5), was the choice of int [] just syntactic sugar to make array objects look like C/C++ arrays?

I read something online that incorrectly stated that standard int [], etc arrays in Java were passed as copies, rather than passing references to the arrays, in analogy with the basic numerical types, and ended up overwriting an array when I thought I was modifying a copy. Can I chalk this up as a design choice to make things simpler to ...

ContentPane and JProgressBar not visible

I have created a JDialog extension that has one component, a JProgressBar, inside the content pane. The JProgressBar is public because I want the value to be set by the owner class. When I create a new Dialog, the content pane doesn't appear at all, resulting in whatever is behind it being displayed instead of the progress bar: Since I'...

Change color of WindowsPlacesBar in JFileChooser

This is a followup question to my previous one: http://stackoverflow.com/questions/1241984/need-filedialog-with-a-file-type-filter-in-java I've got a JFileChooser (using that instead of a FileDialog so I can have a file type filter) and I've managed to style it pretty decently for our darker color scheme option except for that little p...

Parsing standard date to GMT

Hey guys, Can someone show me a piece of java code that parses this date: 2009-08-05 INTO THIS GMT DATE: 2009/217:00:00 ==== what i have so far is: java.text.SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd"); java.util.Calendar cal = Calendar.getInstance(new SimpleTimeZone(0, "GMT")); format.setCal...