java

Should JUnit tests be javadocced?

I have a number of JUnit test cases that are currently not documented with Javadoc comments. The rest of my code is documented, but I'm wondering if it's even worth the effort to document these tests. ...

getting ghostscript to take in files with spaces in their name (like something in "my documents")

I'm trying to run this command to use ghostscript (from java) but Whether with single quote ' or " or nothing at all I get an error Error: /undefinedfilename in ('c:\\Documents) gswin32c.exe -q -dNOPAUSE -sDEVICE=tiffgray -sOutputFile=C:\polter.tiff -r300 'c:\Documents and Settings\polter.pdf' -c quit any ideas? ...

Tagsoup and XOM on android

Can i use Tagsoup and XOM on android 1.6 without any performance problems ? ...

Java JPA Inner JOIN with WHERE statement

Hi folks, I want to annotate following structure: I have this query: SELECT A.*, BES.*, BES_2.* INNER JOIN BES ON A.a = BES.a AND A.b = BES.b INNER JOIN BES AS BES_2 ON A.a = BES_2.a AND A.b = BES_2.b WHERE (BES.c = N'foo') AND (BES_2.c = N'bar') I have the entities Job (representing A) and JobEndPoint (representing BES). The Job...

Drag & drop with JLabel

Hi, Can I drag a JLabel and insert into it a custom object or should I use another component? But I have to use TransferHandler with exportAsDrag. My code: final JLabel label1 = new JLabel("Drag here"); Collection<Person> person= new ArrayList<Person>(); //Register transferhandler objects on them label1 transfer itss //foreground col...

Linux Daemon written in Java location

I'm currently writing a Java daemon. I'm writing a script that will have the standard daemon commands (start, stop, restart, status) and I'm trying to decide on where things should go when installing the daemon. My current idea is: PID File: /var/run/myapp.pid Daemon Script: /etc/init.d/myapp Java App (.jar): /usr/bin/myapp Logs: /var/l...

Hibernate Transaction question

Hi there, I'm using Hibernate with a JTAFactory - in my case: jBossJTA - I've configured my hibernate.xml with the current JTA, now maybe I'm doing something wrong, my dao code looks like this try{ ses = sessionFactory.getCurrentSession(); ses.beginTransaction(); doSomeWork... session.getTransaction().commit(); }catch(Exception...

Eclipse: Most useful refactorings

Every now and again, I make use of the Eclipse refactoring feature. Some techniques are more obvious then others and some I never tried. What refactoring is most useful for you and why? Note: I find this presentation very useful, perhaps because it is example driven therefore easy to understand: "Refactoring for everyone - How and why...

Send Email Attachement using byte[] with Java-Mail

I have a byte array wich i wish to add as an attachement to an email i am sending. Unfortunally i can't find how to attach it as a byte array, the solution i have uses disk files (which i dont want since i dont want to write the byte array just so i can attach it). I've found one solution that involves creating an object that extends D...

Why does Eclipse crash with Xmx, XX:MaxPermSize above certain values?

Running Eclipse 3.5.1, JDK 1.6.0_17 on WinXP SP3 32Bit with 3.5 gigs of RAM. I'm aware of the known Eclipse best practices, still trying to figure out eclipse.ini. This will launch: -Xmx588m and this won't: -Xmx589m. Same with -XX:MaxPermSize. Anything above -XX:MaxPermSize=140m won't launch. The screen of death is simlar to this (tak...

Temporary conversation not ending after ExternalContext.redirect()

Hi. I'm working in a project using Seam and JSF. For some reason (don't ask me, I don't know) the people before me decided to redirect the user to the response page through a FacesContext.getExternalContext().redirect(). The problem I'm seeing is that some pages, when redirected to themselves, never release the conversation (the conversa...

Collection exploration in validator interceptor

Hi all. A question about Java-Hibernate-Validator. I need to access to a collection attribute when my validation system intercepts an entity insert/update. I mean, my model defines A class with a set of B elements. When I call saveOrUpdate(a), the onSave/onFushDirty method of my interceptor is invoked. In that moment I need to know the...

Java Code Review: Generate a subgraph

I'm using JGraphT and I want to generate a subgraph, like this: If there's a graph like {stuff -> a -> b -> stuff}, and you ask for the subgraph in direction of {a -> b}, you'll get {a -> b -> stuff}. (stuff = collection of nodes and edges, -> = an edge, a and b are nodes.) My idea is as follows: if the start is A, and the sink is B, r...

Java 1.5 Script Engine

Since Java 1.6 there is this nice Script Engine Manager which let's i.e. execute JavaScript scripts in run time. Is there something similar in functionality in Java 1.5? ...

SVG Elliptical Arcs with Java

I recently wrote a java program transforming a SVG document to HTML/Canvas: It was easy to translate a path such as d="M 0 0 L 100 100 z" to something like GeneralPath L= new GeneralPath(); L.moveTo(0,0); L.lineTo(100,100); L.closePath(); However I don't know how to translate the Elliptical Arc command to Java/GeneralPath. For exa...

How to remove a row in two-dimensional array

I have a simple array, sort of like this 1 2 3 4 5 6 7 8 9 6 2 7 2 9 6 8 10 5 2 6 4 7 8 4 3 2 5 9 8 7 5 9 7 4 1 10 5 3 6 8 2 7 3 7 2 So, let's call this matrix[5][9]. I wish to now remove every row within this matrix that contains a certain value, in this case 10, so I am left with... 1 2 3 4 5 6 7 8 9 2 6 4 7 8 4 3 2 5 5 3 6 8 2 7 3...

Getting the original secretkey from hex format

This is the hex format of a secret key used for AES encryption 00010203050607080A0B0C0D0F101112 Can i generate the original SecretKey format or byte array from this? If so how? ...

Retrieve JAVA Annotation Attribute

How can I retrieve the value of an annotation on the annotated method?? I have: @myAnnotation(attribute1 = value1, attibute2 = value2) public void myMethod() { //I want to get value1 here } ...

gxt + j2ee hosted mode

Hi. I'm trying to develop a jee+gxt application. I have an rpc call which calls a session bean's method. If I compile the project and run it in the browser, it works fine, but when I use hosted mode I get an exception like this: (edited for readability) Exception while dispatching incoming RPC call ... Caused by: java.lang.NullPointe...

Eclipse won't believe I have Maven 2.2.1

I have a project (built from an AppFuse template) that requires Maven 2.2.1. So I upgraded to this (from 2.1.0) and set my path and my M2_HOME and MAVEN_HOME env variables. Then I ran mvn eclipse:eclipseand imported the project into Eclipse (Galileo). However, in the problems list for the project (and at the top of the pom.xml GUI edit...