java

simple generic list in java

Why are java generics so tricky? I thought I finally understood, but eclipse gives me an error at the line in somOtherMethod below using either of the getOuterList methods below. protected List<?> getOuterList() { // blah blah } protected List<? extends Object> getOuterList() { // blah blah } protected void someOtherMethod() { ...

Is Gant 100% Ant compatible?

I wrote some Groovy code, and I'd like to integrate it with the existing Java code. We'd like to be able to keep our ant scripts, and only add the needed Groovy functionality. Will Gant allow us to keep our existing scripts? ...

Trying to load icon from jar file

Hi, I am trying to load icons from a jar file. I have both tried to load it from classes within the jar file as well as classes outside the jar file. outside of the jarfile - returned a null exception java.net.URL imageURL = LoadHTMLExample.class.getClassLoader() .getResource("icons/mouse.png"); in side of the jar file in...

Prevent Java from loading library more than once

I have several classes that use the same JNI library, called "jni". In each of those classes, I have a System.loadLibrary() call in the class's static initializer: Class class1 { static{ System.loadLibrary("jni"); } ... } Class class2 { static{ System.loadLibrary("jni"); } ... } The only proble...

Frame control on mpeg2 videos using JMF

Hi I was trying to use the FramePositioningControl on mpeg2 videos for frame seek using Java Media Framework(JMF) but it always returns null. To be more clear, I am using FramePositioningControl on player object to do forward, rewind on videos programatically. I want to know whether frame seek can be achieved through alternate means li...

Newlines in string not writing out to file

I'm trying to write a program that manipulates unicode strings read in from a file. I thought of two approaches - one where I read the whole file containing newlines in, perform a couple regex substitutions, and write it back out to another file; the other where I read in the file line by line and match individual lines and substitute o...

Simple Java stand-alone server container/framework?

For the last couple of years I've had my head in Python, where there are numerous choices for simple, minimal frameworks that allow me to stand up a website or service easily (eg. web.py). I'm looking for something similar in Java. What is the simplest, least-moving-parts way of standing up simple services using Java these days? I'm loo...

Yaml Parser choking

Hey guys, I have a yaml snippet ... passwordregexp: '.{8},[0-9],[^0-9A-Za-z ],[A-Z],[a-z]' passwordregexpfailmessage: |- Contain at least 8 characters Contain at least 1 Number Contain at least 1 Special Character Contain at least 1 Upper Case Letter Contain at least 1 Lower Case Letter passwordresetperiod: 1000 pd...

Java HTTP Proxy

I am working on a project where we'd like to pull content from one of our legacy applications, BUT, we'd like to avoid showing the "waiting for www.somehostname.com/someproduct/..." to the user. We can easily add another domain that points to the same server, but we still have the problem of the someproduct context root in the url. Sim...

How do I handle multiple key presses in a Java Applet?

I am teaching myself, from online tutorials, how to write games in Java. I am using Java Applets to create a Pong game. each paddle is controlled from different keys for 1v1 competition. this works fine if both users are hitting the keys at different times. but when one key is being held down and then another key is held down(ex: holdi...

Explanation of how classloader loads static variables

Ok so this is a newbie question on java, but i can't seem to get my head around it. I have the following code inside my class private static final String [] LIST_CODE = gerarListCode(); private static final int [][] LIST_INTEGER = new int [][] { {947,947}, {110,103}, {947,958}, {110,120}, {947,954}, {103,107}...

java servlet: generate zip file from BLOBs

I'm trying to zip a large number of pdf files (stored as BLOBs in the DB) and then return the zip as an attachment to the user. What's the best way to do this without running into memory issues? Another note: I actually need to merge some PDFs prior to adding them to the ZipOutputStream. Therefore, a couple PDFs will need to be store...

Have you ever had a client express concern over the services you provide simply because you use PHP?

We've been toying around with the idea that some of the reason we're not getting a higher caliber of client is because we've made it known that one of our primary partnerships is with an open source application vendor that provides a product built on PHP. Some clients we've talked to that don't even have the budget for "enterprise langua...

EventAggregator for Java ?

Is there an equivalent of Microsoft's Prism EventAggregator for Java? ...

Open Source Expression Engines (Java)

Are there any good open source expression engines for java? I am not looking for a rules engine (which implement conditionals and logic). I want to be able to define a number of "facts" and dynamically generate expressions based on these facts. For example: Say I have facts such as: Lemons=$5 IceCubes=$1 Cups=$2 ...

Efficient copy from one file to another

I'm building a system in Java which has to copy a subset of a file into another file (not necessarily to the beginning of the file). I.e. I have the following parameters: File srcFile, File dstFile, long srcFileOffset, long dstFileOffset, long length Several threads could be reading from the same source-file and writing to the same des...

catching EmptyStackException vs. Testing is Stack is empty.

I have a Stack object being worked on by multiple threads. One of the threads is a worker thread which performs a pop operation on the Stack object. I wanted to handle the case where the Stack is empty and I see two options try{ Object obj = (Object) d_stackObj.pop(); } catch (EmptyStackException e) { ...} OR if( ! d_sta...

Java - Collection Selection

What generics collection class can I use that provides both mapping and array-like functionality. For example, I want to map a String to a Double and I want to reference the value using the key as the index. collection[key] = collection[key] + double Does the Google collections library provide such functionality? Thanks. ...

What should a junior Java developer know?

What skills should a junior Java developer have? I'm also interested in iPhone (Objective-C) development. What technologies/languages should I know to get a position as a Java developer or an iPhone/Obj-C developer? J2SE preferable... What would be better - study only Java/Objective-C or try to work with two? ...

Java Getters: Always execute specific method

Is there a way to define a method, which is called everytime I call a get? I have an Object Contact and don't want to set updateLastUsed(); in about 30 Getters for my Members. ...