java

JNA Resources for OS X

I am looking for reading material on using JNA on OS X, there lots of examples on the web for windows but i can't find anything for OS X. I know that the idea is the same but i have zero cocoa experience. So anyone know any simple examples of using JNA to access cocoa functions? ...

Out of container JNDI data source

I would like to configure a DataSource using JNDI in a Java SE app. What is the best way to do this? So far, I've come across 2 projects: Apache Naming. The project page has a specific example for configuring a data source, but it looks like the project is super old and no longer active. JBossNS. It looks like it's easy to configure a...

Could someone explaining the reasoning behind some of these PMD rules?

DataflowAnomalyAnalysis: Found 'DD'-anomaly for variable 'variable' (lines 'n1'-'n2'). DataflowAnomalyAnalysis: Found 'DU'-anomaly for variable 'variable' (lines 'n1'-'n2'). DD and DU sound familiar...I want to say in things like testing and analysis relating to weakest pre and post conditions, but I don't remember the ...

Tool to Execute JPQL Queries?

Is there any sort of tool available which allows one to execute JPQL queries against a database "directly"? I would like to type JPQL queries directly into a window and execute them. Of course it would probably require me to do quite a bit of configuration so that it would be aware of my JPA entities, etc., but I guess it could be done...

How can I reconcile the following error: "JVM cannot use large page memory because it does not have enough privilege to lock pages in memory"?

Please help!!! I wonder how can I reconcile the following error: "JVM cannot use large page memory because it does not have enough privilege to lock pages in memory"? The settings are: set JAVA_OPTS=-Xms20g -Xmx20g -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseLargePages -Duser.timezone="GMT" %DEBUG% This happen on Windows 2003 ...

How to show items on a jList in java?

I have made a java GUI program and have added a jList on that GUI so as to print output of the program on that jList by adding an item by calling listBox.addElement(""); // where listBox is an instance of jList But the problem is that the items are not being displayed at the time of addition. They are being shown when the program is ...

Creating an X509 Certificate in Java without BouncyCastle?

Is it possible to sanely create an X509 Certificate in Java code without using the Bouncy Castle X509V*CertificateGenerator classes? ...

Hibernate ConstraintViolationException in join table

I'm running into a ConstraintViolationException when I try to save an object with a @OneToMany map in it. Hibernate either seems to think that I'm trying to put a NULL into the mapped list or it may be putting it there itself. The problem seems to happen sporadically: with some databases it's easily reproducible, but with others I can't ...

Ways to fill a list in Java

Hi, I would like to know your opinions on which you find is a better approach to have a list filled up by a different method. I know there isn't a definite answer, but I would like to see reasonable pros and cons. Approach 1. private List<Snap> snapList; snapList = getSnapList(); Approach 2. private List<Snap> snapList = new ArrayL...

Java mechanisms at use in lambdaj closures

Lamdbaj allows the definition of closures in the Java language, various examples can be found here My question is regarding the underlying Java mechanisms at use, for instance, to define the println closure, the following code is used: Closure println = closure(); { of(System.out).println(var(String.class)); } This closure can be s...

Eat, Sleep and Breathe Unit Testing/TDD/BDD

I do write unit tests while writing APIs and core functionalities. But I want to be the cool fanboy who eats, sleeps and breathes TDD and BDD. What's the best way to get started with TDD/BDD the right way? Any books, resources, frameworks, best practices? My environment is Java backend with Grails frontend, integrated with several exter...

Java Content Assist / Refactoring with External Build tools

We currently build our Android (Java) projects using the built-in Eclipse build tools. Then we have a separate ANT build script for automated building, unit testing, etc. I would like to switch to using the ANT script inside Eclipse as well. What I can't figure out is how Eclipse content assist and refactoring tools will interact with s...

With which versions of GWT does Seam work?

Hello, I recently tried to combine SEAM and GWT in a project - but failed using GWT 1.7.1 and Seam 2.1.2 CR2 and Seam 2.2.0 GA (if you have any ideas why - here is the post). I was wondering: Do you have any experiences which versions of GWT work with which version of SEAM out of the box? With workarounds? Thx! (PS: For Seam < 2.1.0 an...

default root folder for an eclipse project

I am attempting to read a file as follows: File imgLoc = new File("Player.gif"); BufferedImage image = null; try{ image = ImageIO.read(imgLoc); } catch(Exception ex) { System.out.println("Image read error"); System.exit(1); } return image; I have a file named "Player.gif" as shown in imgLoc, but I do not know where to pu...

What is the best Clustering or Distributed System solution for Java applications

What are the best approaches to clustering/distributing a Java server application ? I'm looking for an approach that allows you to scale horizontally by adding more application servers, and more database servers. What technologies (software engineering techniques or specific technologies) would you suggest to approach this type of pro...

Getting a list of embedded fonts used in an external PDF

I have been playing about with iText to try get a list of embedded fonts used in an external PDF. Am i missing something or is this just not very well documented? Could anyone explain it to me or suggest an alternative? Preferable the font names and any associated data. ...

Java FileWriter overwrite

Hi Everyone, I have a piece of code that generates new data whenever there is new data available as InputStream . The same file is overwritten everytime. Sometimes the file becomes 0 kb before it gets written. A webservice reads these files at regular intervals. I need to avoid the case when the file is 0 bytes. How do it do this? Wil...

Using ACE ORB Event Service on HPUX 11.xx from Java

I have an Avaya PDS12 using HPUX 11.11 which I have installed an old version of ACE ORB on. I am trying to develop a Java client that uses the event service to get notification of calls being placed on the PDS (delivered through the event service). Here is the exception I get when trying to narrow on the event service: org.omg.CORBA.B...

How to replace string only once without regex in Java?

I need to replace a dynamic substring withing a larger string, but only once (i.e. first match). The String class provides only replace(), which replaces ALL instances of the substring; there is a replaceFirst() method but it only takes regexp instead of a regular string. I have two concerns with using regex: 1) my substring is dynamic...

java.lang.NoSuchMethodError: org.apache.http.protocol.BasicHttpContext: method <init>()V not found

Hi I am trying to put up a small webapp but I am getting above error. Below is my code HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("SomeURL"); // Using a URL local to my machine // after setting nameValuePair and setting it on httppost httppost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); ...