java

Is Component.getGraphicsConfiguration thread safe?

There are many methods you shouldn't call if you are not on the AWT event thread. These are generally methods that manipulate the UI in some way. Is this the case with Component's getGraphicsConfiguration(...)? It is only a getter but it appears to cause a deadlock if the event thread is waiting on the thread calling this method. Whi...

Hibernate and special chars

Hi, Imagine I have a database with one table, this table has only one field named "word" and some other data, imagine also that user can search data by typing contents of this field. I have a lot of words on this table with Spanish accents. Word examples ácido autobús camión Question If user searches for "acido" or "ácido" words t...

How can a Java process with -Xmx1024m occupy 3GB resident memory?

It's a Java web application on Websphere6.1, Solaris 10, JDK 1.5.0_13. We set the maximum heap size to 1024m. jmap shows the heap status is healthy. The heap memory usage is only 57%. No OutOfMemory at all. But we saw very high RSS (3GB) for this java process from ps. pmap shows a block of 1.9G private memory. 3785: /dmwdkpmmkg/was/...

Purpose of empty synchronized block in Java?

I was looking through a Findbugs report on my code base and one of the patterns that was triggered was for an empty synchronzied block (i.e. synchronized (var) {}). The documentation says: Empty synchronized blocks are far more subtle and hard to use correctly than most people recognize, and empty synchronized blocks are almost...

Generate Java classes from .XSD files...?

I have a gigantic QuickBooks SDK .XSD schema file which defines XML requests/responses that I can send/receive from QuickBooks. I'd like to be able to easily generate Java classes from these .XSD files, which I could then use to marshal XML to Java objects, and Java objects to XML. Is there an easy way to do this...? Ideally, it wou...

Why is javac 1.5 running so slowly compared with the Eclipse compiler?

I have a Java Maven project with about 800 source files (some generated by javacc/JTB) which is taking a good 25 minutes to compile with javac. When I changed my pom.xml over to use the Eclipse compiler, it takes about 30 seconds to compile. Any suggestions as to why javac (1.5) is running so slowly? (I don't want to switch over to the...

Java bean machine

Here is what I'm suppose to accomplish: Write a program that stimulates a bean machine Your program should prompt the user to enter the number of balls and the number of slots in the machine. Simulate the falling of each ball by printing its path. EX. Enter the number of balls: 5 Enter the number of slots: 7 ...

Is there a way to resolve system properties in a web.xml file?

I added a system property in my run.conf of my JBOSS like this: JAVA_OPTS="$JAVA_OPTS -Dfoo=bar" Now my question is, if there is a way to resolve this property in a web.xml file in a way something like this: ... <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:applicationContext-common.xm...

Is it possible to have multiple PropertyPlaceHolderConfigurer in my applicationContext?

I need to load a specific applicationContext.xml file according to a given system property. This itself loads a file with the actual configuration. Therefore I need 2 PropertyPlaceHolderConfigurer, one which resolves the system param, and the other one within the actual configuration. Any ideas how to do this? ...

Problem with calling rsync+ssh from java on windows

I'm having trouble calling rsync from java on windows vista with cygwin installed. Its strange as pasting the exact same command into a command shell works fine. My test java call looks like this. String[] envVars = {"PATH=c:/cygwin/bin;%PATH%"}; File workingDir = new File("c:/cygwin/bin/"); Process p = Runtime.getRuntime().exec("c:/cy...

Active rendering and the EDT (Swing animation)

How should I run animation in a Swing applet? I have an animation thread performing active rendering and it initially animates fine. Sometimes (anywhere from 1 minute to 2 hours later) it begins to fail to update the screen and only the sounds occur. I believe this is due to the fact that the paint is not performed from the EDT causing ...

Java implementation of planarity testing/planar embedding

Is there a free Java implementation of any of the major planarity testing algorithms? Boyer-Myrvold, de Fraysseix-Rosenstiehl, heck, even Hopcroft-Tarjan. I've been reading the papers and they all seem fairly complex, and I'd rather skip all the work of implementing them myself if someone else has already done so. ...

Swing: How do I set a component height to the container's height?

I want to make a component to occupy the maximumAvailableHeight of the Container. In the code that I have pasted below for example, I have made the root frame to be 800,600. I want to set the height/width of only that frame (and I do not want to try and pixelify its children). If I run this, I see a badly aligned UI. Firstly, I want a p...

Eclipse 3.4.2 compiling Java 1.6 on Mac OSX

My Eclipse 3.4.2 does not compile Java 1.6 on Mac OS 10.5.6, does anyone here got it working? Seems that no matter which JRE I choose, it keeps compiling using 1.5. ...

Is C++ like resource management possible in Java

In C++ we have Resource Acquisition Is Initialization (RAII) pattern, which extremely simplify the resource management. The idea is to provide some wrapping object for any kind of resources. The wrapping object's destructor is then responsible for releasing the resource, when it's going out of its scope. For example: { auto_ptr<int>...

How to use Oracle jdbc driver fixedString property?

Oracle pads values in char columns so if I insert "a" in a CHAR(2) column then I cannot get that record by comparing that column to "a", I should get it by comparing it to "a ". Right? To solve this problem the Oracle jdbc driver has the property fixedString but I cannot make it work. (look for fixedString here) I'm using ojdbc14.jar d...

Java servlet filter not working on login

I've written a filter class to add a P3P header to every page. I added this to my web.xml: <filter> <filter-name>AddP3pHeaderFilter</filter-name> <filter-class>com.mycompany.AddP3pHeaderFilter</filter-class> </filter> <filter-mapping> <filter-name>AddP3pHeaderFilter</filter-name> <url-pattern>/*</url-pattern> </filter-m...

Use an existing KerberosTicket to Bind to Ldap and search for users attributes.

Is there a way in Java to query Active Directory for a users attributes given an existing javax.security.auth.kerberos.KerberosTicket that was forwarded to my code? I know I want to use Ldap to do the search but I am confused on how to use this KerberosTicket object to Bind to ldap. Currently I am using Spring-Ldap and Spring-Security to...

How to send signed emails from java?

What APIs/Libraries do you recommend for sending signed emails from Java code? What are the requirements on our company's SMTP-Server to make it transport these signed mails, if any? We already hava a PKI infrastructure running, so certificates are no issue here. ...

Getting Bundle [] in Eclipse of all the bundles

I am writing an application that uses Equinox as my OSGi framework. I am trying to discover all of the bundles that are known at the time that my bundle is registered. I attempted to use the following line to retrieve all of the available bundles. However, EclipseStarter.getSystemBundleContext().getBundles(); gives me a warning of....