java

How to set the java.library.path from Eclipse

How can I set the java.library.path for a whole Eclipse Project? I'm using a Java library that relies on OS specific files and need to find a .dll/.so/.jnilib. But the Application always exits with an error message that those files are not found on the library path. I would like to configure this whole project to use the library path. ...

Q about AbstractApplicationContext.getBeansOfType() and getBean()

We have the following legacy 2.0.7 Spring code: final Map<String, MyClass> secondaryFactories = (Map<String, MyClass>) context.getBeansOfType(MyClass.class, false, true); return (MyClass) context.getBean("myClass"); where context is an instance of org.springframework.contex...

How to convert a .WAV audio data sample into an double type?

Hi, I'm working on an application that processes audio data. I'm using java (I've added MP3SPI, Jlayer, and Tritonus). I'm extracting the audio data from a .wav file to a byte array. The audio data samples I'm working with are 16 bits stereo. According to what I've read the format for one sample is: AABBCCDD where AABB represents l...

Handling creation of ORM objects prior to persistence/generation of primary keys?

Bear with me as I try to simplify my issue as much as possible. I am creating a new ORM object. This object has an auto generated primary key which is created on the database using as an identity. Within this object, is a child object with a many to one relationship with the parent object. One of the attributes I need to set to create t...

Why am I getting a NullPointerException in this for loop?

here is my code: Comic[] comix = new Comic[3]; comix[0] = new Comic("The Amazing Spider-man","A-1","Very Fine",9240.00F); comix[0].setPrice((Float)quality.get(comix[0].condition)); for(int i=0;i<comix.length;i++){ System.out.println("Title: " + comix[i].title); } Why am I getting a NullPointerException when this code run...

In Java, is there any way to get a Locale given its display name?

That is, if I have "English (United States)" I'd like to get "en-US", or an appropriate java.util.Locale. It looks like the API is a one-way street, but perhaps I'm not looking in the right place. Thanks in advance. ...

Is this a valid strategy for generating then including html into jsp file?

Hi all, I need a sanity check on my strategy to best fulfill the requirements of a project. Basically I have an xml file that will need to be parsed periodically and html output displayed (xslt is not an option). My thought is that I can use a single .jsp page to check an application variable that stores the last parsed date to know if ...

Downgrade Java code 1.5 to 1.4 (bonus points: J2ME, Blackberry!!!)

I want to port some existing j2se libraries (e.g. Apache Compression libs) to use for Blackberry development, but there is a catch (and not just one). First, most java libs extensively use j2se collections and data types that are typically missing on j2me platforms — but that's theoretically solvable thanks to open-source j2se api imple...

Problem - Java Web Service Consumed by .NET

I am facing an issue while consuming a java web service from .NET. I am able to provide the input to the web serive but not able to get back the result. The result is a custom object which is created in Java with one long, one short and one string variable. But the output I am getting from .NET is that long and short are always defaulted...

Creating a assertClass() method in JUnit

Hi, I'm creating a test platform for a protocol project based on Apache MINA. In MINA when you receive packets the messageReceived() method gets an Object. Ideally I'd like to use a JUnit method assertClass(), however it doesn't exist. I'm playing around trying to work out what is the closest I can get. I'm trying to find something simil...

JiBX on Android (or any other build-time bytecode manipulating library)

I'm considering the use of JiBX for a project that will have to run on both Blackberry and RIM. While it seems like J2ME use of JiBX has been considered by the community (as per JiBX jira tickets), Android is relatively new. The question is, therefore, this: has anybody had any success (or issues, for that matter) using JiBX on Android,...

In Java, how can I avoid an HTTP 404 getting a file:// URL with special characters in it?

First I'll provide a tiny code snippet here: String path = "".equals(url.getPath()) ? "/" : url.getPath(); java.io.File f = new java.io.File(path); if (!f.exists()) { this.code = 404; // http Not Found return; } Here, the URL's type is java.net.URL,and its value has this format: file:///directory1/directory2.../filename t...

How do I gain access to the data source in Spring?

I read this post, but I don't understand how I can gain access to the request using a ThreadLocal or DataSourceLookup or AbstractRoutingDataSource. I read every post but it still doesn't work. How do I gain access to my request's dataSource parameters and dynamically create connections with them? ...

how and where to catch exceptions in a j2ee application

ok, im working in a j2ee project that has 2 branches in the repo and i'm ordered to mix them. i was coding and then netbeans ask me "unreported exception blah bla bla must be caugth or declared to be thrown" and gives me the choice of just handle each exception or just throw it hoping someone else catches. The classes i'm working with ...

Java's interactive shell like ipython

I am quite new to java, and I would like to learn java just like python, with the interactive shell IPython. I try a few a them, like beanshell, jython, jythonconsole, JyConsole... Almost all of them don't have the function of tab completion like ipython. Is there anything similar to that? Thank you. ...

Is it possible to name a variable using a variable in Java?

What I would like to do is have a loop that names a certain number of variables each time. So sometimes when I run the program, this loop will create say 3 variables a1, a2 & a3 but other times it could name more, e.g. (if this sort of thing were possible): for(int i=1; i<=n;i++) { int ai = i; } So in the case (for i=1) the name o...

Problems passing class objects through GWT RPC

I've run through the Google Web Toolkit StockWatcher Tutorial using Eclipse and the Google Plugin, and I'm attempting to make some basic changes to it so I can better understand the RPC framework. I've modified the "getStocks" method on the StockServiceImpl server-side class so that it returns an array of Stock objects instead of String...

ant's java task can't find a jar in the jre/lib/ext directory

I put "stax-utils.jar" in the extensions directory ([JAVA_HOME]/jre/lib/ext), but ant's java task can't find it, giving: java.lang.NoClassDefFoundError: javanet/staxutils/IndentingXMLStreamWriter Strangely, it works for compilation: ant's javac task can find it. The problem is only with running code, with ant's java task... If I us...

Strange behaviour of ArrayList

Hello everybody. I am writing a website using JSP, JSTL, Servlets and JavaBeans. At one point of my code, I am trying to use an ArrayList of objects, and a strange thing is happening: when I add the first object it is fine, and when I add a second object it adds it in the second place, but the object at index(0) gets the same values as...

Future of Aspect Oriented Programming

I am a newbie in the area of AOP. The first time I coded something applying concepts of AOP, I was thrilled to understand how aspects eliminate cross cutting patterns in your application. I was overwhelmed by the thought of solving cross cutting patterns like security, logging, transactions, auditing and etc applying AOP. However, when ...