java

How do synchronized static methods work in Java?

If I have a util class with static methods that will call hibernate functions to accomplish basic data access. I am wondering if making the method synchronized is the right approach to ensure thread-safety. I want this to prevent access of info to the same DB instance. However, I'm now sure if the following code are preventing getObject...

What is the best way to expose a WCF service so that it can be easily consumed from Java/CXF?

We've written a WCF service to be used by a Java shop, who is using CXF to generate the adapters. We're not that familiar with Java, but have exposed the service using basicHttpBinding, SSL, and basic authentication. Integration tests show that a .NET client can consume the service just fine. However, the Java shop is having trouble c...

unsatisfied link: SolarisParallel using rxtx to replace java comm api in Windows XP

Hi everyone, i'm trying to use the rxtx 2.0 jars and dll to use the java comm api in windows xp, i copied the RXTXcomm.jar to jre\ext and rxtxSerial.dll and rxtxParallel.dll to jre\bin When I run the program I got the following error: Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library....

Java generics

Why is the following seen as better than the old way of casting? MyObj obj = someService.find(MyObj.class, "someId"); vs. MyObj obj = (MyObj) someService.find("someId"); ...

Which Rich Client Platform to use

Hi all, We recently started to develop a Java desktop app and management has requested that we make use of Rich Client Platform. I know of three for Java namely: Eclipse RCP - www link to ecipse rcp, Netbean RCP - Netbeans RCP web site, Spring RCP - spring rich client Has anyone got any experience in any of these and if so what are ...

Setting catalina.policy to allow file access by servlets

We have a locally-developed triple store based on b-trees which I want to use for persistent storage in a number of servlet applications. Rather than embed the b-tree index files in the servlet .war, I would like to store them at a known location and have the servlets access them directly. This all works in Jetty, but raises a security e...

TrueType parsing in Java?

Is there a simple library that can parse a True Type font file and give me a list of vectors/points for me to render it myself? I'm talking about something similar to freetype, but for Java. ...

Java Constructors

I am trying to learn how to specify class constructors in Java. I am starting to understand that they specify the types of instance variables of objects made from that class. They also can be used to set the instance variable initial values. The follow example is from the Java tutorial on Sun's website: public Bicycle(int startCadence, ...

Java and GNU gettext for internationalization

Has anyone had any experiences developing large Java applications using GNU gettext for internationalization? I find that I really like having the English text in my source code, but I want to make sure that what I'm doing is practical for the relatively large software project I am part of. If you have experience with this, what are yo...

Big class decomposition in Java

I have just started to learn Java and is curious is it any good practice in Java for good object decomposition? Let me describe a problem. In big software project it's always a big classes like 'core' or 'ui' that tends to have a lot of methods and are intended as a mediators between smaller classes. For example, if user clicks a button ...

toolkit & methods for extracting text bounds in 'searchable pdf'

I have a "searchable pdf" aka 'image files with invisible but selectable text'. (When this file is opened in Acrobat, I am alerted "You are viewing this document in PDF/A mode.") I need to extract the bounding rectangle of each word in this document. Any suggested toolkits and the methods for accessing the "invisi-text" words' boundin...

how to use a ByteBuffer with an OutputStream

I need to put the contents of a java.nio.ByteBuffer into an java.io.OutputStream. (wish I had a Channel instead but I don't) What's the best way to do this? edit: and I can't use the ByteBuffer's array() method since it can be a read-only buffer. edit 2: I also may be interspersing writes to the OutputStream between using this ByteBuff...

Why choose Buckminster over Maven?

I've been using Maven for several months and I am pretty comfortable with how it works conceptually and in practice. I have also looked at Buckminster quite extensively (but have not gotten to running samples yet) to try and figure out what it is and how it compares. The documentation is poor. For instance, they use terminology like Bui...

How can I port this Java code to C#?

I am looking at a pattern implemented in Java and have some questions about how it aligns to (can be ported to) C#. Java: class Foo { private Class someClass; ... } class Bar { private Field some Field; } First, Class stores an instance of a domain object. It looks like Java exposes reflection methods on the type which ...

Assistance Needed with Java Colt Matrix Package

Can anyone tell me how you can delete columns from a matrix using the Colt library? TIA. ...

How to handle properties with dynamic defaults

I often have a situation like this when creating simple data objects. I have a property called Label that should have a default based on the Name of the object. So if no label is set then the Name is used otherwise use the set Label. A simple example in C# public class FooBat { public string Name { get; set; } public string La...

Nonblocking algorithm to generate unique negative numbers

I recently refactored a piece of code used to generate unique negative numbers. edit: Multiple threads obtain these ids and add as keys to a DB; numbers need to be negative to be easily identifiable -at the end of a test session they're removed from the DB. My Java algorithm looks like this: private final Set<Integer> seen = Collec...

How can I make it so that a JPanel updates itself once the window scrolls?

I'm new to Java so this is probably pretty simple, but I'm not sure how to make it work. Basically, I have a class which I use to draw a grid, which extends JPanel. I put this class in a window, inside a JScrollPane. The scroll works the way I want it to, except the drawing inside my class doesn't update itself once the window scrolls. ...

Is it possible to set an environment variable at runtime from Java?

Is it possible to set an environment variable at runtime from a Java application? In Java 1.5 java.lang.System class there is the getenv() method, I would only need a setenv() method... Is it possible to modify the environment variables in the java process itself; not in the child process. Is it possible to achieve it through JNI? And ...

Convert Collection to List

I am using TreeBidiMap from the apache collections library. I want to sort this on the values which are doubles. My method is to retrieve a Collection view of the values using Collection coll = themap.values(). Which naturally works fine. Main Question: I now want to know how I can convert/cast (not sure which is correct) coll into a Li...