java

Extend my Java application with R?

Im building an application that i want to have extended with modules that does some nr crunching and i would like to have R for that. What are my best options for extending my Java application with R? ...

How to read windows .exe file version?

I need to parse the file version and product version from windows exe and msi files. Could you point me to the file specification or the library (preferably in Java) that does that? UPDATE: It turns out I cannot use winapi, as the code needs to run on linux as well... ...

How would you create xml files in java

I am creating software that creates documents, (Bayesian network graphs to be exact), and these documents need to be saved in an XML format. I know how to create XML files, but I have yet to decide how to organise the code. At the moment, I plan on having each object (i.e. a Vertex or an Edge) have a function called getXML() (they will...

Android. Brightness Change

Hi, I am trying to resolve following task: smooth change of brightness from 100% to 0%, but can't gain effect of smoothness. Want to emphasize that I am using following approach of brightness change. The recommended one. WindowManager.LayoutParams lp = window.getAttributes(); lp.screenBrightness = floatPercent; window.setAttribut...

slow construction of tree structure from XML

I'm parsing an XML document into my own structure but building it is very slow for large inputs is there a better way to do it? public static DomTree<String> createTreeInstance(String path) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstanc...

How do i upgrade a module in a running NetBeans Platform application from commandline or script?

How do i upgrade a module in a running NetBeans Platform from commandline or script? When developing NetBeans Platform Apps in NetBeans IDE it is possible to hot deploy/update modules in a running instance of the application you are working on. How can i do this from ex commandline or an ANT script so i can do rapid development of NetBea...

Does this basic Java object pool work?

Does the following basic object pool work? I have a more sophisticated one based on the same idea (i.e. maintaining both a Semaphore and a BlockingQueue). My question is - do I need both Semaphore and BlockingQueue? Am I right that I don't need to do any synchronisation? import java.util.Collection; import java.util.concurrent.ArrayB...

What would cause a NullPointerException when running a JAR from the command line, but not from an IDE?

I have a project in Eclipse. When I run it from inside Eclipse, everything works just fine. However, when I run the Ant build script and execute the JAR either from the command line or using a batch script, I get a NullPointerException. The NullPointerException in question is being thrown from a third-party JAR that I compiled from sour...

Ensure valid data or protect against invalid data? Both?

I would like to know, in a practical sense, on a large scale (Java - my case)project is it better to just code defensive logic to protect against invalid data in the DB or just take the time to go through and make sure that you don't accept any invalid data? Remember, the issue here is that there are many cases where a null is ok, and th...

How do I tunnel RMI using Tomcat

Hi, I'd like to setup RMI to pass through port 80 on a java servlet.. (To pass through the firewall) I have a Tomcat server and i'm looking for the module that will catch the RMI http request and pass it to the RMI layer on the server machine. I've read that RMI automatically handles this on it's side. Is there a step-by-step guide to ...

QR codes image generator in java (open source but no GPL)

Hi, I'm seeking an open source QR codes image generator component in java (J2SE), but the open source licence mustn't be a GPL licence (needs to be included in a close source project). BTW, i can't access the web from the project so no Google API. ...

Selenium is to Web UI testing as ________ is to Windows application UI testing

I'm interested in UI testing a client only Java application. What is the most popular framework for doing so? What is your recommended framework? Also, why doesn't Selenium do this (or does it)? It seems to me that anything that can test a web app should be able to test a windows app. ...

How to convert from parsing with Dom to parsing with SAX

I'm parsing an XML document into my own structure using DOM, but in another question I was advised to use SAX, how would I convert the following: public static DomTree<String> createTreeInstance(String path) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory docBuilderFactory = DocumentBuilde...

Java Thread Shared Object Synchronization Issue

I'm having issues with Synchronized not behaving the way i expect, i tried using volatile keyword also: Shared Object: public class ThreadValue { private String caller; private String value; public ThreadValue( String caller, String value ) { this.value = value; this.caller = caller; } public synchronized String getValue() { ...

Run Junit-Tests from several projects conveniently fast in Eclipse

Is there a way to run JUnit-Tests from several projects conveniently fast in Eclipse? The JUnit-Runner lets you define a package or a folder where from all contained tests are executed. Is there a way to do this with tests from several projects inside Eclipse? Preferably it should be via the Junit-Runner. If there is some way to have ...

Ways of producing XML in Java

What are the ways of producing XML in Java? Simple question, multiple answers possible. I'd like a small discussion about the pros and cons of the various methods, as it seems the current community's opinion is very focused: any way but not with println(). Why? Can you explain it? To make my question more community wiki, I'd also lik...

Instanceof and Type-casting Techniques

I have a question about technique and implementation, rather than an actual problem to solve. Recently I created an abstract class, let's called it A, which defines the common behaviors of its subclasses. I use this to construct several subclasses B, C, and D, which are then passed to some other method outside of the superclass-subclas...

Object's property is changed in the Map even without using put()?

Hi I got the code from a book: public class Container { Map<String, Object> components; public Container() { components = new HashMap<String, Object>(); Properties properties = new Properties(); try { properties.load(new FileInputStream("components.properties")); for (Map.Entry entry : properties.en...

When do you validate connections in a connection pool?

I'm implementing a connection pool in Java (i.e. a pool of java.sql.Connections). When should I check that connections are still valid? I don't want to do it before I lend them. Should I do it when they are returned? Every time? Is there a clever way to schedule checking? ...

Fast NIO, asynchronous HTTP Server for Java

Following on this question I am actually in the phase of finding the right HTTP container for one of my projects, too. I looked at several containers but I'm still not sure which one will be best suited for high load AJAX only requests. Apache Mina looks quite promising, but relatively complex as well. The asynchronous web server impleme...