java

Validate an XML File Against Multiple Schema Definitions

I'm trying to validate an XML file against a number of different schemas (apologies for the contrived example): a.xsd b.xsd c.xsd c.xsd in particular imports b.xsd and b.xsd imports a.xsd, using: <xs:include schemaLocation="b.xsd"/> I'm trying to do this via Xerces in the following manner: XMLSchemaFactory xmlSchemaFactory = new...

Simple database-like collection class in Java.

The problem: Maintain a bidirectional many-to-one relationship among java objects. Something like the Google/Commons Collections bidi maps, but I want to allow duplicate values on the forward side, and have sets of the forward keys as the reverse side values. Used something like this: // maintaining disjoint areas on a gameboard. Locat...

Using NetBeans IDE 6.7 with J3D's Canvas3D Container

I keep telling myself that this should be simple, and yet I'm completely lost. Let me start by saying that I'm new to NetBeans IDE, and that I am using it out of necessity. I don't really know much about it yet. I have successfully designed my main window for my application. The right side of the application is essentially a large windo...

Is it in an anti-pattern to always use get and set methods to access a class's own member fields?

In Java classes is it considered good or bad practice to access member fields with their getters and setters? e.g which is better: public Order { private Agreement agreement; public Agreement getAgreement() { return agreement; } public void process() { //should I use: getAgreement().doSomething(); ...

Google App Engine: Memcache or Static variable?

Well, I think I have a very basic doubt here: I'm developing an app on GAE (Java) and performing a query to the datastore that returns a lot of entities, so I need to cache it. I was using memcache and it was working great, but if I keep the list of entities in a static variable, the whole request goes as twice as fast than using memca...

xsd.exe/XMLSerializer equivialent for Java ?

Is there something akin to the .NET xsd.exe for java - generating classes from a schema that you can easily de-serialize ? - or , What's the common practice for parsing and pull out/validate the content xml documents in Java ? Traversing a DOM tree and littering code with XPath queries to get the data you need seems quiet messy. ...

Eliminating unnecessary log4j setup output

I'm using log4j in an app I'm developing to eventually run inside Tomcat/JBoss, but right now I'm running it from inside Eclipse. I've configured it to write to a ConsoleAppender using a log4j.xml file and passed it as a system property, and all of my logging output works. The problem is that log4j spits out a bunch of bootstrap/startup...

Android Eclipse Classpath - want to add classpath container path but eclipse won't let me.

I'm using Eclipse to learn to develop Android applications in Java. I haven't used Eclipse before. The project I'm trying to use (supplied by OReilly as part of 'Android Application Development') is MJAndroid. When attempting to run the project, the Run fails, and the Problems tab mentions com.java.Object can't be found, and Eclipse ask...

JVM calltree snapshot for VisualVM

I am trying to use VisualVM to profile a Java (Sun JDK 1.6) standalone application. I have a scripted performance test environment, where I can run my application and get it to report some metrics I care about. Is there some way to get JVM to collect some CPU profiling snapshot which I can later analyze with VisualVM? I am looking for...

Is there a GZIP J2ME library?

Is there a gzip compression library that will work on J2ME? ...

Profiling native methods in Java - strange results

I have been using Yourkit 8.0 to profile a mathematically-intensive application running under Mac OS X (10.5.7, Apple JDK 1.6.0_06-b06-57), and have noticed some strange behavior in the CPU profiling results. For instance - I did a profiling run using sampling, which reported that 40% of the application's 10-minute runtime was spent in ...

Selecting elements in a JEditorPane

I'm creating a Java application where the user can search through a list of objects, which are then displayed in a JEditorPane window using a dynamically generated table whose size varies by the amount of results returned. I then want to allow the user to select and edit the objects. (The Java objects, not the HTML code) Is this feasibl...

QP solver for Java

I'm looking for a good easy to use Java based Quadratic Programming (QP) solver. Googling around I came across ojAlgo (http://ojalgo.org). However, I was wondering if there are any other/better alternatives. ...

JToolbar resizing within JSplitPane

I'm trying to create an application where there is a JSplitPane which contains the document tree on the left side and the current editor pane on the right. The editor pane has a toolbar as part of the edit pane. My problem is that when the JFrame containing the JSplitPane is resized as soon as the right component of the split pane reache...

build XML out of user's input

Hi guys, I wanted to see some of your ideas/opinions/suggestions on the following problem. The idea is to have a simple webapp (java webapp) collecting user's input that essentially is turned into an XML file? The final XML file has to be valid and has to conform to a DTD. What would be a good way to dynamically collect an input prese...

General purpose build tool with good Java support?

I really need an easy to use build tool which supports multiple languages with strong Java support. I have tried Scons but found the Java support lacking. Is there anything else out there? I'm not excited about learning yet another build tool. Also, I really don't want a build tool which is difficult to use without an IDE since I use ema...

Efficient data structure for comparing items with most common attributes

I need a suggestion for an efficient data structure for the following problem. I have two lists of students (male and female) with their respective classes (sorted by date) they have already taken. The list is already alphabetized with their last name, first name. A user will give a student name, ie. student X, and what the program nee...

Reading UTF8 strings from a server through http using MIDP.

I want to read UTF-8 strings from a server that I have control of, using java MIDP. My server is sending UTF-8 data. The following code gets close: c = (StreamConnection) Connector.open( myServer, Connector.READ_WRITE); InputStream is = c.openInputStream(); StringBuffer sb = new StringBuffer(); ...

Using Java keystore in PHP

I'm looking to port a small Java security library to PHP. The Java implementation makes use of a keystore for signing some stuff and I'm wondering how to go about recreating this functionality in PHP. Of course the original Java implementation must still work with the same key pair/keystore. I have very little experience with PHP and ...

How to get the User ~/Library path in Java for the Mac OS

On the Mac OS, from what I understand you're suppose to store information in "/Library/Application Support/Your App Name" if the files are to be read by everyone. However when it comes to writing, this is an admin only folder. Therefore, if you want to write data, you need to store it to "~/Library/Application Support/Your App Name". No...