java

Java/J2EE standard practices and design choices

I have a couple of design/architectural questions that always come up in our shop. I said "our", as opposed to "me" personally. Some of the decisions were made and made when J2EE was first introduced so there are some bad design choices and some good. In a web environment, how do you work with filters. When should you use J2EE filte...

How do I change the location of ejb-jar.xml in my maven project?

When building my EJB project with maven, maven expects the ejb-jar.xml to be in META-INF/. However; I need to be able to put it in directoryA/META-INF. maven-ejb-plugin doesn't seem to provide a parameter for specifying where ejb-jar.xml is. Can you point me in the right direction? ...

Prevent Ant to perform a task if a file is older than an other file

Hi all, how can I prevent Ant to process a task if a source file is older than the current target. For example, I created a javacc file MyParser.jj and there is no need for javacc to re-generate the file MyParser.java as long as the MyParser.jj is older than MyParser.java. Thanks ...

Java memory leak detection tools

I am now trying to detect memory leak in our java codes. I understand there are a few of detection tools such as memory manager that comes with eclipse, and NetBeans. Based on your experience, which is the best free tool out there I can use? I tried memory manager, but it is not very easy to detect where the leak is. I heard that NetBean...

Losing connection to a webservice via https "No X509TrustManager implementation available"

Hi I have a really weird issue with Java and SSL certificates. Hope someone can help. A web is running in a cluster of 3 identical servers All servers contain "Application A" which is a JSR-168 portlet. "Application A" uses a web service that runs on httpS://webservices.domain.com/ "Application B" also uses a web service on httpS://w...

instantiating spring bean outside the container (for testing)

I have following in my applicaionContext.xml <bean id="IbatisDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="oracle.jdbc.OracleDriver"/> <property name="url" value="jdbc:oracle:thin:@123.210.85.56:1522:ORCL"/> <property name="username" value="mydb"/> ...

How to hide my url params?

I've got several Portlets with some links in them, all I want is to hide the URL params. So I thought it would be easy to include some jQuery code, which builds a form for each and binds a click event on it to submit the form. This does not work. The action request isn't hit for some reason. Does anyone have a different suggestion for...

Can I put try / catch around an OS API that crashes?

I use a Windows OS library to manipulate image files. Sometimes it crashes deep inside it for no apparent reason—all the inputs are reasonable and its not a threading issue. The crash is memory A/V. So, what are the down sides to something like this: try { pFoo = OsAPIThatCrashes(); } catch { pFoo = NULL; } Will that even work?...

Creating Java stubs for a DLNA service / client? (or, What the hell is a <scpd> root tag in an XML file?)

Looking at the specifications for DLNA, most of the metadata communication appears to be soap based. However I can't find anything like a WSDL for any of the various services. Instead there is some sort of service description language that looks like this: <scpd> <serviceStateTable> <stateVariable> <Optional /> <name...

Copy and pasting multiple items to the clipboard in Intelli-J IDEA

In Intelli-J IDEA is to possible to have multiple items in your clipboard and selectively choose the item before pasting. Also, what would the keyboard shortcuts be? ...

Flex Compiler Api: Adding images in Java

Hi there, I have a very specific question. I want to compile an ActionScript project within Java in-memory with the help of the Flex Compiler API ( http://livedocs.adobe.com/flex/3/compilerAPI%5Fflex3.pdf ). My last problem is to add images (jpg, png) that are embedded in the project to the compiler. I don´t see a possibility to do thi...

creating a JAR file programmatically

I created a Jar file from my java code : public void create() throws IOException{ FileOutputStream stream = new FileOutputStream(this.packagePath); JarOutputStream out = new JarOutputStream(stream, new Manifest()); out.close(); //jarFile = new JarFile(new File(this.packagePath)); } I get a META-INF directory, with a MANIFEST....

Spring formBackingObject, Business Object Creation, and Factories

Design question for using Business Objects as formBackingObjects in a Spring SimpleFormController. Our controller's responsibility is to allow an End User to add a new Business Object to our web application. So we are passing our Business Object though the formBackingObject(HttpServletRequest request) method. However, we've run into a...

JMF Registry could not add item (Vista)

Hello, I'm using JMF to capture video stream (webcam) on my Java project. The camera I'm using is recognized by JMF (JFMStudio) and I manage to get the video stream. However, on JMF Registry Editor - there's a list of available capture devices, when I click "Add" on one of the items (including the one I need) I get a "Could not add it...

Can a java class member variable decleared as `native`?

For instance, is the following legal public class Foo { private native int bar; } ...

Setting namespace and schema using java dom

I have a root element in my output xml document that has no attributes: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <root> .. </root> I need it to look something like this: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="my.x...

Quantum Tic Tac Toe AI

In my data structures class, we've been assigned a project in which we are required to make a fully functioning Quantum Tic Tac Toe game in which a player faces a bot that plays to win. The professor suggested we use a game tree in our AI. However, as usual, I am looking for something more challenging. Can anyone suggest a better, mor...

Character Enconding in my java classes in Eclipse is messed up. How to fix it?

I got a eclipse project that was working OK. One day I had to format my machine, so I copied my workspace into a backup, after installing eclipse again, I imported my projects from my backed up workspace. What happened is that it corrupted all the string that contains special characters.. like.. é, são, etc.. to É, são... Is there ...

Another neural network knight's tour conundrum

I've done my best to make a simple java implementation of the neural network knight's tour finder but I'm completely stumped as to why it fails to work.. there are 6 classes, 3 for the GUI which im pretty sure works fine, and 3 to deal with the actual logic etc. If you are wondering, this is inspired by Yacoby's python offering He h...

asynchronus web services, callback problem

I have a asynchronous web service using axis2 which I call two different times using the same CallBack Hanlder as follows : stub.startGetData("Foo",callbackhandler) stub.startGetData("bar",callbackhanlder) ServiceCallBackhandler callbackhandler = new ServiceCallBackhandler() { .....}; //ServiceCallBackhanlder and stub are generated...