java

How do I create an identity matrix of arbitrary size in Java?

Is there a utility to create an identity matrix of specified size in Java? ...

Many to many relationship in java google ap engine

how would i go about creating a many-many relationship among data objects in google app engine (using jdo) The app engine page talks about 1-many and 1-1 but not many-many. Any code example will be highly appreciated ...

java iterator/iterable subinterface

I have an interface for a variety of classes, all of which should implement Iterator, so I have something like public interface A extends Iterable<A> { ...otherMethods()... } For the concrete classes, however, this means I must use public class B implements A { public Iterator<A> iterator() {...} } when I'd prefer (or at least, thi...

Parent Key Not Found - Spring Transaction Management

I am working with your typical three layered application that has a presentation layer, a business layer, and a DAO layer. It is a Java web application that uses Spring MVC, Spring Security, and Spring's transaction management from the business layer down. It is communicating with an Oracle 10g database. I have a business layer method ...

java - adjusting jslider looks on windows laf

Hi all, been trying this for a while now and can't seem to get it to work. I wrote a little GUI app that uses the OS's default Look And Feel. While I wrote it on linux, it is mainly intended to be used on Windows. The JSliders under linux are fine by me, but on windows the thumbs(sliders? I don't know the right word) become very narrow,...

Spring Security oddity in <intercept-url> when specifying method

I've been playing around with Spring Security a bit and noticed the following oddity. When I specify the <http> block like this in my security context XML. <http> <http-basic/> <port-mappings> <port-mapping http="8080" https="8181"/> </port-mappings> <intercept-url pattern="/url1**" access="ROLE_ROLE1" require...

Class libraries for Java's immense verbosity

I recently got into Java. I have a background in dynamic languages and I'm finally figuring out why people complain about Java's verbosity. Are there any class libraries out there that address this issue? I'd much rather type something like "String text = someClass.stdin()" instead of the 8 or so lines it takes to get user input in Java....

Java regex matching to replace substrings

How can I replace all occurences of java substrings like stuff="-9888777666" , stuff="123", with the substring stuff="0"? The double quotes are actually a part of the string. ...

Java exception not caught

Why are some methods in Java not caught by Catch(Exception ex). This is code is completely failing out with an unhandled exception. (Java Version 1.4). public static void main(String[] args) { try { //Code ... }catch (Exception ex) { System.err.println("Caught Exception"); ex.printStackTrace(); exitCode = app.FAILURE_E...

Saving an Array to a Text file in Java

I'm trying to print the values of an int array to a local file. However, I can't seem to find a way to print the integers out in their standard form (1,2,3) instead of a heap address: ([I@1befab0) My code fragment is below: PrintWriter pr = new PrintWriter("file"); for (int i=0; i<views.length ; i++){ pr.pr...

How can I extract and use images from an archive in a Jasper report?

I need to put images in my Jasper reports that match rows in a database. I have the image data in proprietary archive files which I can easily extract in Java code. I need to know how to connect my Java code to the Jasper report to make the extraction process happen, something like BIRT's onRowSets() method. (I need overview documentatio...

Java Project Manager Help in Eclipse (help with program versions)

When I program I often end up making 5 or 6 different versions so that way if I mess up I can return back to an older version. In the Eclipse IDE, is there a way I can just click "create new version" or something so I don't have to make an entirely new project and copy and paste the previous source code to the new version I just made? ...

Student's Result program in Java

import java.io.DataInputstream; class Student { int roll; void getdata(int r) { roll=r; } void putroll() { System.out.println("The roll number is: "+roll); } } class Test extends Student { int sub1,sub2; void getmarks(int a, int b) { sub1=a; sub2=b; } void putmarks() { System.out.println("Marks 1= "+ sub1 + "\n Marks 2= "+su...

Java regex to remove all trailing numbers?

I want to remove any numbers from the end of a string, for example: "TestUser12324" -> "TestUser" "User2Allow555" -> "User2Allow" "AnotherUser" -> "AnotherUser" "Test123" -> "Test" etc. Anyone know how to do this with a regular expression in Java? ...

Load DLL (using JNA) inside an OSGi bundle

OSGi cannot find my DLL file, and I can't seem to figure out why. Currently I have the DLL file (foo.dll) at the root of my bundle, I've also tried having it in a libs directory. The Manifest for the bundle in question looks something like this: Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: foobundle Bundle-SymbolicName...

Error in Java Expression

Does the following Java statement have an error in it? If so, what is it? P *= x/y ...

Java Generics: casting to ? (or a way to use an arbitrary Foo<?>)

So, I have some code that looks approximately like (truncated for brevity - ignore things like the public member variables): public class GenericThingy<T> { private T mValue; public final T[] mCandidates; public GenericThingy(T[] pCandidates, T pInitValue) { mCandidates = pCandidates; mValue = pInitValue; ...

Search for file in directory with multiple directories

Here's my goal. I want to be able to pass a parent directory and a filename to a method that searches for that specific file in the directory and any sub-directories. Below is the code I have been working with but can not get it to do exactly what I want. It will find the file I specify but will not return anything. private static File ...

Compare log4j and Logger

How does The JDK's Logger compare to Apache log4j? Which one is better for new projects that target Java 6? How do they compare in terms of flexibility and configurability? ...

java.sql.SQLException: No suitable driver found for jdbc:derby:

Hi .. I'm a beginner with jdbc ... I have a problem running this code : This code uses appache derby and in order to make it work I first started the derby server.. java -jar "C:\Program Files\Sun\JavaDB\lib\derbyrun.jar" server start And then started the program java -classpath derbyclient.jar -jar TestDB.jar I se...