java

Getting the path to the directory of a given class file

I was confronted with code which tries to read some configuration files from the same directory where the .class file for the class itself is: File[] configFiles = new File( this.getClass().getResource(".").getPath()).listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.ends...

Hibernate ManyToMany with Join table problems on update

Dear all, I am trying to make a ManyToMany association work for all CRUD operations I have to entities : Places and Events Places can hold multiple events and an events can take place in multiple places In first case I had In class PlaceDto @ManyToOne( targetEntity=EventDto.class, cascade = { CascadeType.PERSIST,...

Deploying webapp's resources to maven repository?

This question is a bit of a "best-practice" question, my team is new to Maven and I am looking for the best way forward on this topic: When working on a project that has packaging = war, what's the best way to deploy it to your Maven repository (such as a company-wide Nexus installation)? For example, let's say you have a webapp where ...

getting into sentiment analysis

I've got a requirement of determining whether the entered sentence is positive or negative.... First I thought it is something to do with Social Network analysis and later I realised that it is Sentiment analysis. My first question is what is the difference between these two? I think SNA itself uses SA... plz correct me if i am wrong... ...

What is the maximum length a URL can be to be opened in a J2ME browser?

What is the maximum length URL? This is may be handset dependent; on a desktop, it is definitely browser dependent, as discussed in this question. I am interested in specifications or references as much as empirical data. My particular usecase is passing a very long (about 1600 character) URL to a MIDlet.platformRequest(String url), w...

How to simulate different network scenarios ? (in Java)

I’m building a client server application that should operate 24/7. The applications is designate to detect network failures (using a heart beating) and reconnect to the server asap. The first test that I made is just stopping the client or the server and then starting again and everything works fine. I’m wondering if there is any tools ...

BouncyCastle Last Byte Decrypt Problem

I am decrypting an XML file from the file system using Bouncy Castle. I output the decrypted text and get a fatal error SAXParseException on the very last byte of data. Below is my decryption method and the setup of the cipher object. I was initially using cipher streams, and everything worked perfect (commented out code was my stream)...

Fuzzy date parsing with Java

Are there any libraries for Java that allow you to interpret dates like "Yesterday", "Next Monday", ... ...

How to export a remote java webstart app thru WAN ?

Hi, I've got the following problem. A client is looking for better latency to access a forex trading java web app (.jnlp) that is stored on a third party server. I can provide him access to one of our servers (running linux) that is geographicaly closer to the trading portal (rather than connecting directly to the trading server, less...

Most efficient way to add attribute to begining of massive XML file in Java?

What is the fastest way to add an attribute to the root element of a massive XML file? These files are too large to be read into memory and I'd like to avoid as much of an I/O penalty as possible. ...

How to make Hibernate only query the default mapping?

I have an entity class: Cabbage.java package womble; public class Cabbage { private int id; // getters, setters, etc. } That I've got mapped to two separate database tables as follows: Cabbage.hbm.xml <hibernate-mapping> <class name="womble.Cabbage"> <!-- Using the default entity and table name. --> <id name="id" uns...

Customizing Label Fonts in Swing

In my swing application, I have different types of text I'd like to display. For example, I want to display a heading text before a list of choices, something like: Select choice: a b I want the "Select Choice" label to use the "Heading" font (something I define), and the choices to use the "Choice" font. This pattern w...

Parsing a simple language for title formatting

Hi, I'm writing an audio player using java, and I want a title formatter similar to foobar2000. Examples are: $if($strcmp(%album artist%,%artist%),%artist%,$if2(%album%,Unknown)) or [%album%][ '('CD $ifgreater(%totaldiscs%,1,%discnumber%,)')'] first example returns a string, and if it is same for sequential tracks in a playlist, th...

Unmarshalling XML to existing object using JAXB

I have an xsd generated from a set of existing java classes and currently it successfully unmarshalls XML messages into the object as expected, however what I'd like the ability to do is where I have an existing instance of the Object have the unmarshaller simply update the fields that are contained within the message passed to it for e...

Basics in Flex and ActionScript

I have a class with a method name, and now i have a Flex MXML... how would i call the id of the component in my ActionScript class... ...

JSP compilation to string or in memory bytearray with Tomcat/Websphere

I am doing conversion to image and PDF output. I need an input HTML document that is generated by our application JSPs. Essentially, I need to render the final output product of a JSP based application to a String or memory and then use that string for other processing. What are some ways that I can just invoke the JSP renderer to get...

Spring MVC or Grails?

I'm new to the web programming world, and I'm trying to learn about various Java MVC frameworks available. Through my research, I came across Spring MVC and Grails. My question is: which one is better for developing enterprise web applications, or is there another option I haven't run across yet? Important considerations: Must be su...

Programmatically determine what JDK/JRE's are installed on my box

Is there a standard way to do this? I realize this can be somewhat platform dependent. Our product right now is only supported on Windows - so I suppose that's what I'm interested in right now. The only things I can think of are to either scan the registry or crawl the file system. Scanning the file system seems like it can take a re...

Data structures for message passing within a program?

I'm trying to write a simple RPG. So far, each time I try to start it instantly becomes a mess and I don't know how to organize anything. So I'm starting over, trying to prototype a new structure that is basically the MVC framework. My app starts execution in the Controller, where it will create the View and Model. Then it will enter the...

Java Beans: Overglorified Associative Arrays?

I don't understand the nature of Java Beans that well. Well, at least how I see them used in some code-bases that pass through our shop. I found this question: http://stackoverflow.com/questions/315142/java-beans-what-am-i-missing The accepted answer there makes it look like programmers tend to abuse Java Bean (which I really don't do...