java

Why I can't parse a SimpleDateFormat with pattern "MMMMM dd" in Java?

I need to parse a string like "February 12, 1981" as a Date. I use SimpleDateFormat. But if I do: new SimpleDateFormat("MMMMM dd, yyyy").parse("February 12, 1981") I get java.text.ParseException. I tried to reduce it to see where the problem is. First: new SimpleDateFormat("MMMMM").parse("February") works. Then: new SimpleDateFor...

Eclipse RCP Toolbar buttons with the Eclipse Look

In Eclipse, its easy to specify buttons for your toolbar using the ActionSets extension point. However, when I need to specify some items programmatically, I can't get the same look. I don't believe that the framework is using native buttons for these, but so far, I can't find the right recipe to match the Eclipse look. I wanted to se...

Java RMI: Client security policy

grant { permission java.security.AllPermission; }; This works. grant file:///- { permission java.security.AllPermission; }; This does not work. Could someone please explain to me why? ...

JPA - Unknown entity bean class

Hopefully, I can explain this issue properly. I have 3 classes that deals with my entities. @MappedSuperclass public abstract class Swab implements ISwab { ... private Collection<SwabAccounts> accounts; ... } @Entity @Table(name="switches") @DiscriminatorColumn(name="type") @DiscriminatorValue(value="DMS500") public class DmsSwab ...

Is there anything inherently wrong with long object invokation chains?

I've organized my code so that the data is organized hierarchically. I find myself crawling up the tree using code like the following: File clientFolder = task.getActionPlan().getClientFile().getClient().getDocumentsFolder(); Now, since I'm not drilling down into the task object, I'm drilling up to its parents, I don't think I'm loos...

UnsatisfiedLinkError: The specified procedure could not be found

I'm writing some JNI code in C++ to be called from an applet on Windows XP. I've been able to successfully run the applet and have the JNI library loaded and called, even going so far as having it call functions in other DLLs. I got this working by setting up the PATH system environment variable to include the directory all of my DLLs ...

How to check for key being held down on startup in Java

I'm trying to write a resolution selection dialog that pops up when a program first starts up. To prevent boring the user, I want to implement the fairly standard feature that you can turn off that dialog with a checkbox, but get it back by holding down the alt key at startup. Unfortunately, there is no obvious way to ask java whether a...

Extract all string from a java project

I have a rather big number of source files that I need parse and extract all string literals and put them in a file as play old java constant. For exemple: Label l = new Label("Cat"); Would become: Label l = new Label(Constants.CAT); And in Constants.java I would have: public final static String CAT = "Cat"; I do not want the strin...

Java development in a Perl shop: How to select the right tool?

My group is a Perl shop in an organization that is very heterogenous. Although we support the odd Java, PHP, or Python installation, we're using Perl for nearly all of our web applications and systems/data marshalling tasks. All of our boxes are Linux, although we interface with IIS systems as well. We're coming under some pressure fr...

Cause of No suitable driver found for...

I'm trying to unit test (JUnit) a DAO i've created. I'm using Spring as my framework, my dao (JdbcPackageDAO) extends SimpleJdbcDaoSupport. The testing class (JdbcPackageDAOTest) extends AbstractTransactionalDataSourceSpringContextTests. I've overriden the configLocations as follows: protected String[] getConfigLocations(){ return n...

Is it good practice to use the XOR (^) operator in Java for boolean checks?

I personally like the 'exclusive or' operator when it makes sense in context of boolean checks because of its conciseness. I much prefer to write if (boolean1 ^ boolean2) { //do it } than if((boolean1 && !boolean2) || (boolean2 && !boolean1)) { //do it } but I often get confused looks (from other experienced java developers, n...

OpenJDK7: What essential ADTs are not Implemented in OpenJDK7 ?

What Abstract Datatypes should be added to OpenJDK7 ? ...

How do I invoke a java method when given the method name as a string?

If I have two variables: Object obj; String methodName = "getName"; Without knowing the class of obj, how can I call the method identified by methodName on it? The method being called has no parameters, and a String return value - a getter for a Java bean. ...

Dynamic breadcrumb generation - how to do?

I'm in the early phases of developing a brand spanking new site with Spring + Tiles. The site needs dynamically generated breadcrumbs. What I mean by dynamic is that the user may reach a certain site from multiple starting points. If I have views for Customers, Orders and Products, the user could reach a Product directly: Products -> P...

How do I force a tomcat web application reload the trust store after I update it

I have the following problem. My tomcat 5.5 based web application is using a trust store to verify SSL connections. The application allows the user to add or remove CA certificates to be used in the verification process. However, adding or removing certificates from the trust store doesn't change a thing. The application 'recognizes' onl...

What are the differences between the different saving methods in Hibernate?

Hibernate has a handful of methods that, one way or another, takes your object and puts it into the database. What are the differences between them, when to use which, and why isn't there just one intelligent method that knows when to use what? The methods that I have identified thus far are: save() update() saveOrUpdate() saveOrUpdat...

How do you force constructor signatures and static methods?

Sorry in advance if the question is naive... Is there a way of forcing a (child) class to have constructors with particular signatures or particular static methods in C# or Java? You can't obviously use interfaces for this, and I know that it will have a limited usage. One instance in which I do find it useful is when you want to enfor...

Top reason not to use EJB 3.0 again?

The scenario You have developed a webapp using EJBs version 3. The system is deployed, delivered and is used by the customer. If you would have to rewrite the system from scratch, would you use EJBs again? Yes: Don't answer this question, answer this one instead. No: Provide the top reason for not using EJBs again, based on your pe...

Java: Writing a DOM to an XML file (formatting issues)

I'm using org.w3c XML API to open an existing XML file. I'm removing some nodes , and I'm adding others instead . The problem is that the new nodes that are added are written one after another , with no newline and no indentation what so ever. While it's true that the XML file is valid , it is very hard for a human to examnine it. Is the...

Spring MVC : Binding 3 dropdowns to a date property in SimpleFormController

How should I configure the class to bind three dropdowns (date, month, year) to a single Date property so that it works the way it works for 'single request parameter per property' scenario ? I guess a should add some custom PropertyEditors by overriding initBinder method. What else ? ...