java

java message bundle - property file naming convention when using variants?

Hi, what is the naming convention for message bundle property files when using variants? for instance, if the locale is EN US, the property file lookup will be message_en_US.properties though, what if I instantiate a local EN US though the variant string is "DEVL" what is the search order? ...

Is it possible to display Swing components in a JSP?

I was wondering if I could pop up JOptionPanes or other Swing components from within a browser using JSP. ...

How to play sound in JavaFX?

I'm experimenting with JavaFX making a small game. I want to add sound. How? I tried MediaPlayer with media defined with relative source attribute like: attribute media = Media{ source: "{__FILE__}/sound/hormpipe.mp3" } attribute player = MediaPlayer{ autoPlay:true media:media } It doesn't play. I get "FX Media Ob...

Best way to manage database connection for a Java servlet

What is the best way to manage a database connection in a Java servlet? Currently, I simply open a connection in the init() function, and then close it in destroy(). However, I am concerned that "permanently" holding onto a database connection could be a bad thing. Is this the correct way to handle this? If not, what are some bette...

Can unchecked warnings be avoided when overriding a method with raw type parameters?

I am extending a class defined in a library which I cannot change: public class Parent { public void init(Map properties) { ... } } If I am defining a class 'Child' that extends Parent and I am using Java 6 with generics, what is the best way to override the init method without getting unchecked warnings? public class Child exten...

Java: When is Java 6 ready for end-user desktop application?

I am writing a desktop application written in Swing developed using Java 1.5. Some of the users seem to be using Mac, but I am interested in Java 6's scripting feature (Java 6 ships with Rhino). Java 6, although it came out almost 2 years ago, doesn't seem to be widely in use. I also hear Apple ships Java 6 only for Intel 64 Macs only. I...

Full Resolution Camera Access in j2me

I'm trying to do an image capture on a high end Nokia phone (N95). The phone's internal camera is very good (4 megapixels) but in j2me I only seem to be able to get a maximum of 1360x1020 image out. I drew largely from this example http://developers.sun.com/mobility/midp/articles/picture/ What I did was start with 640x480 and increase...

Eclipse project directory

Is there a way to get the directory of a project in Eclipse? We are writing a plugin that will allow the user to select files, and then run some processes on those files. I would ideally like to be able to get all the files with a certain extension, but that is not necessary. ...

Is there an expandable list of object references in Java?

In Java, we can always use an array to store object reference. Then we have an ArrayList or HashTable which is automatically expandable to store objects. But does anyone know a native way to have an auto-expandable array of object references? Edit: What I mean is I want to know if the Java API has some class with the ability to store re...

What are the benefits of Java?

I always hear that programmers try to pick the right tool for the job. I've never programmed in Java, so I was wondering What are its benefits? Why is it so popular? What should I use it for? I just program recreationally. Is there anything about it that makes it particularly fun?? ...

Java performance of StringBuilder in a loop

I've a performance related question regarding use of StringBuilder. In a very long loop I'm manipulating a StringBuilder and passing it to another method like this: for (loop condition) { StringBuilder sb = new StringBuilder(); sb.append("some string"); . . . sb.append(anotherString); . . . passToMethod(sb.toStri...

Slim application server for demonstrating a web app?

I have a little pet web app project I'd like to show someone who doesn't have an application server themselves (and who has no clue about application servers). What is the easiest and quickest way for them to get my WAR file running with zero configuration, preferably something I could send along with or bundle with the WAR file? Is the...

Limit for URL length for "rundll32 url.dll,FileProtocolHandler"?

I have a long URL with tons of parameters that I want to open in the default browser from Java on a Windows system using Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+url) For short URLs like "http://www.google.com" this works fine. But for long URLs (say, 2000 characters), this simply does absolutely nothing at al...

Scheduled data backup from client to server

Hi! Can anyone point out what technologies would be best suited for an application that backs up data from clients to a server ? The client should choose folders to backup and schedule backups to a server I would also be interested in how would you start developing/designing, how would you build in the shortest time possib...

Escape path separator in a regular expression

I need to write a regular expression that finds javascript files that match <anypath><slash>js<slash><anything>.js For example, it should work for both : c:\mysite\js\common.js (Windows) /var/www/mysite/js/common.js (UNIX) The problem is that the file separator in Windows is not being properly escaped : pattern = Pattern.compil...

Problem with Swing GUI on Macintosh

Hi, I am new to Swing. Are there any specific issues related to customizing the paint operation on the Mac? I have developed a sample application using NetBeans + Swing on Windows. It is working fine. But if I run the same application on a Mac, panels' buttons' labels don't appear on the screen. Only when the mouse over operation is p...

JPA Composite Key + Sequence

Hi, Is it possible in plain JPA or JPA+Hibernate extensions to declare a composite key, where an element of the composite key is a sequence? This is my composite class: @Embeddable public class IntegrationEJBPk implements Serializable { //... @ManyToOne(cascade = {}, fetch = FetchType.EAGER) @JoinColumn(name = "APPLICAT...

Can XFire SOAP server send HTTP 301 REDIRECT to client?

Is it possible to send a HTTP REDIRECT response from inside the XFire SOAP server instead of a regular response? I need this in order to redirect the client to another server based on some checking of method parameters. Also, is redirect handling something that major SOAP clients support? I know HttpClient does, but I'm not sure about ...

Why does addition of long variables cause concatenation?

What does Java do with long variables while performing addition? Wrong version 1: Vector speeds = ... //whatever, speeds.size() returns 2 long estimated = 1l; long time = speeds.size() + estimated; // time = 21; string concatenation?? Wrong version 2: Vector speeds = ... //whatever, speeds.size() returns 2 long estimated = 1l; long ...

WebSphere Portal v.5.1 and AJP?

Hello, is there a way to configure WebSphere Portal to accept AJP connections? E.g. Tomcat/JBoss and Oracle have a specific AJP port. I can't find it in WebSphere, and I'm getting tired of Googlin' around IBM pages. Thank you in forward... Balint ...