java

What is the point behind character class intersections in Java's Regex?

Java's Regex.Pattern supports the following character class: [a-z&&[def]] which matches "d, e, or f" and is called an intersection. Functionally this is no different from: [def] which is simpler to read and understand in a big RE. So my question is, what use are intersections, other than specifying complete support for CSG-like o...

How do you build a JAR in eclipse with a custom manifest file?

I am trying to to build a Felix bundle in Eclipse. This basically includes having Eclipse create a JAR (through export) and adding my custom manifest file, however, I can't seem to get this to work. When I try exporting a JAR file, my custom manifest file shows up in the JAR, but doesn't ever get added to the right location within the JA...

Is there a way to automatically call all the getter methods on an object graph?

I have a collection of java bean objects and each object can have another collection of java bean objects (ie object graph). Is there an easy way to traverse the graph and call all the getter methods? Is there a library already doing something similar like that. ...

Netbeans memory management

I have some Java code that is throwing out of memory exceptions after running for a while. I've investigated the netbeans profiler, and when I do one specific operation the Surviving Generations Metric goes up. However when I reset the program status (not kill it), the Surviving Generations Metric does not decrease. Why is the survivi...

Deep Copy in JPA

I would like to make a deep copy of an entity in JPA. I found an interesting discussion here: http://forums.java.net/jive/thread.jspa?messageID=253092&tstart=0 It sounded like the proposed solution was to set all @Id's to zero. Here's my basic code: //Start a JPA session. EntityManager em= emf.createEntityManager(); em.getTransa...

How can I convert OO Perl to Java?

I inherited large monolithic body of OO Perl code that needs to be gradually converted to Java (per client request). I know both languages but am rusty on my Perl skills. Are there any tools (Eclipse plugins?) that you folks can recommend to ease the pain? ...

Java: proper way to get the class of a primitive array for reflection

I'm trying to use reflection to call a method that takes in a byte array. I'm starting off doing: Class myClass = anObject.getClass(); Class[] parameterTypes = {byte[].getClass();}; But that doesn't work (class expected, } expected) on the byte[] line. Anyone know what I should do? Cast to an Object and declare that the method tak...

SVG Linear Gradient Scale and Translation Question

I have the following radial gradient: <radialGradient inkscape:collect="always" xlink:href="#linearGradient2454" id="radialGradient2460" cx="4022.8572" cy="5451.2656" fx="4022.8572" fy="5451.2656" r="3559.865" gradientTransform="matrix(-0.1071067,-0.1166362,0.1377765,-7.0459663e-2,276.61943,1452.439)" gradi...

Looking for Java Map implementation that supports getKeysForValue

I'm looking for an implementation of java.util.Map that has a method that will return all they keys mapped to a given value, that is, there are multiple keys map to the same value. I've looked at Google Collections and Apache Commons and didn't notice anything. Of course, I could iterate through the keyset and check each corresponding...

HTTPS authentication over WiFi using HttpClient 4

I have Android pet-project DroidIn which utilizes HttpClient 4 (built into Android) to do some form based authentication. I started noticing that people who are using WiFi are reporting connection problems. It also doesn't help that site I'm accessing has self-assigned certificate. Well - the question is (I'm quite vague on WiFi details)...

Java options for web user authentication

I'm looking for a secure user login/session management component for a public web app. Spring Security seems to have potential, are there any other high quality alternatives? Conceptually this is easy and we currently have code that works fine, but I'd rather be using code that has been publicly reviewed for security flaws. Needs: ...

Java web development environment to minimize build-deploy-test cycle time?

What Java web development environment is the best for absolutely minimizing the build-deploy-test cycle time? Web development environment: JBOSS, Tomcat, Jetty? Deploy WAR exploded? Copy WAR or use symbolic links? There are factors here I don't know about. Build-deploy-test cycle? The amount of time it takes to test a change in the bro...

testNG tests extending BaseTest

Hello, We noticed that when testNG test cases extend TestCase (JUnit) those tests start executing as Junit tests. Also, I should probably mention, the tests are run through Maven. Is this a bug or a feature? Is it possible to override this behavior and still run those types of tests as TestNG tests? Do you know a link where TestNG talk...

Java Type Erasure Problem

Hello. I've made an example to demonstrate my problem: Metrical.java public interface Metrical<T> { double distance(T other); } Widget.java public class Widget implements Metrical<Widget> { private final double value; public Widget(double value) { this.value = value; } public double getValue() { return value; } ...

GWT and Key object

I'm writing Java app using GWT on Google AppEngine. So I have JDO Entities on Server side and POJO DTOs on Client's side. For some of my entities I have to use Key objects for ids Pojo's cannot have that object because that is not standard class. is there any easy work around for this so I can use Key object on server side and String or ...

raise "NullPointerException" in Ruby

I previously worked a lot with Java and now I am working more with Ruby. One thing I cannot figure out though is what is the ruby equivalent to the Java "NullPointerException"? I want to test variables when I enter a function and if they are nil I want to raise this type of exception. Is there a specific ruby error class to raise this...

Which serverside Java technology to use with ExtJS

We are plannnig to upgrade the UI framework for our 6-8 year old application written using Struts/JSP/EJB to ExtJS. Just curious as to what is the most popular Java technology on the server people have been using. We were looking into several alternatives like DWR RestEasy Restlet Struts-Json We are diving more towards using DWR but ...

Is it possible for Java apps to use the Aero Glass effect?

Is it possible for a Swing based Java to have the Aero Glass effect as the background under Windows Vista/7? ...

Facebook Java API, sending app-to-user notification

I'm trying to get this to work. This is my utility method for sending an app-to-user notification to a single user. Session id is not needed for that. public Collection<String> notifyUser(String user, String msg) throws FacebookException { FacebookJsonRestClient fbkClient = new FacebookJsonRestClient(FacebookUtil.appApiKey, FacebookUti...

Built-in storage unit conversions utilty in Java?

Hi, there doesn't seem to be an existing util class for converting a storage unit from one to another in Java, am I right? Or is there one actually I wasn't aware of? What I was looking for is something like java.util.concurrent.TimeUnit utility. I can implement the equivalent for storage unit by myself, but just thought I would ask f...