java

When to 'IN' and when not to?

Let's presume that you are writing an application for a retail store chain. So, you would design your object model such that you would define 'Store' as the core business object and lots of supporting objects. Let's say 'Store' looks like follows: class Store implements Validatable{ int storeNo; int storeName; ... etc.... } So, your ...

@ManyToMany Hibernate Question (can add extra field?)

Hi every one, I have these two class(table) @Entity @Table(name = "course") public class Course { @Id @Column(name = "courseid") private String courseId; @Column(name = "coursename") private String courseName; @Column(name = "vahed") private int vahed; @Column(name = "coursedep") private int dep; ...

Font Rendering in Mac vs Windows

I'm writing a Graphically intense application that renders a JLabel offscreen. When I call the following line, ellipsis appear on the mac but not on the windows box. g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); Now, I'm guessing that it's caused by Mac already doing some ...

Caching of instances

Hi all I am just curious about the java memory model a little. Here is what i though. If i have the following class public class Test { int[] numbers = new int[Integer.MAX_VALUE]; // kids dont try this at home void increment(int ind){ numbers[ind]++; } int get(int ind){ return numbers[ind]; ...

Java solution for C++ style compiler directive

I have a Java array: String[] myArray = {"1", "2"}; Depending on a condition that is known at compile time I would like to assign different values: String[] myArray = {"A", "B", "C"}; In C++ I would use something like #ifdef ABC // ABC stuff here #else // 123 stuff here #endif but what to do in Java? ...

Setting default locale for Tomcat Service in Windows XP

I have installed Apache Tomcat 6 as a Service in a Windows XP computer (French) My problem is that Tomcat itself and all webapps (Sonar and Hudson) now show french messages. I want English messages of course so I went to the "Regional Settings" window in Control panel and changed everything to English (US) Tomcat however is still in Fr...

Junit inline comparator initialization error

Hi, I've created a SortedList Class, which has a Constructor that takes a java.util.Comparator as an argument. After running Unit tests on my machine (through eclipse 3.3.0), everything was OK. However, Hudson complaints because it says it can't instantiate my comparator. Here its my simple test (snippets) public class SortedListTest...

Resolving facelets components at runtime

Hello, do you know a way to select a different facelets component at runtime? I've got some of code similar to this: <s:fragment rendered="#{r== 'case1'}"> <div> <ui:include src="case1.xhtml" /> </div> </s:fragment> <s:fragment rendered="#{r== 'case2'}"> <div> <ui:include src="case2.xhtml" /> ...

problem with basic attributes java.sql.Blob

Hi every one, I have this code @Entity @Table(name = "picture") public class Picture implements Serializable { @Id @Column(name = "id") @GeneratedValue private int id; @Column(name = "format", length = 8) private String format; @Basic(fetch = FetchType.LAZY) @Column(name = "context", nullable = true, co...

JFreechart Realtime Combined Plot - Rendering the previous value for a step subchart if no data point has been received

I have a combined plot in JFreechart consisting of 4 timeseries charts with a common time domain axis. The data for the subplots arrives at different rates. For example I may receive a price change event every couple of miliseconds and a position change every minute. I'm currently rendering these series with the XYStepRenderer to produc...

getting started with osgi + felix

Which packages of Felix do I need to get started? There are a zillion of them on the downloads page. (p.s. is the name a reference to the Odd Couple + in contrast to OSGI's "Oscar" reference framework? this occurred to me after reading one of the tutorial pages & I got a chuckle out of it.) ...

How can I change te background color of a Java applet?

Greetings, So far, my code compiles, but it changes white to black and then don't want to change. Supposely it should change from red->orange->green->pink->blue->black.. public void init() { c=new Color[] {Color.red, Color.orange, Color.green, Color.pink, Color.blue, Color.black }; btnNext = new Button("Next...

Java: Anyway to declare an array in-line?

Let's say I have a method m() that takes an array of Strings as an argument. Is there a way I can just declare this array in-line when I make the call? i.e. Instead of: String[] strs = {"blah", "hey", "yo"}; m(strs); Can I just replace this with one line, and avoid declaring a named variable that I'm never going to use? Thanks! ...

self-closing tags with XMLEventWriter

So the question is pretty much as stated in the title. I am doing some xml work and using XMLEventWriter. The big issue I'm having is that I need to create some self closing tags The problem is that I haven't figured out a way to do this with the eventWriter. I have tried everything I can think of using XMLEventFactory but nothi...

Problem with java.util.logging and Lock file

Hi, I have an application that scans a set of files. And this scanning take place parallely. I mean if I upload 5 files, five process will be created and start executing the job parallely. Now For logging the exceptions for the jobs running, there is only one log file. The problem that is coming is, the logger creates a lot of logs file...

Does anyone know if Hibernate and java will work effectively with Access?

I have a small project that doesn't require much disk space, so i considered using an access database. I was wondering if anyone used a Spring + Hibernate + access combination, if so can they post the connection properties. thanks guys ...

Checking patch integrity

Hello all, I am working on j2ee web application and we have the following requirement: it should be impossible to install application patch with arbitrary classes. Right now patches are done by manually adding jars with fixes or even individual classes to server classpath or to application EAR. We also cannot use signed jars since it is ...

Use of getBean as opposed to method injection in Spring

I have an application that has multiple screens and each screen is selected via a button. Each screen contains pretty heavy-weight components so it's important that only the activate screen is in memory - all others should be available for garbage collection. The app uses Spring for the glue and currently it switches screens using getB...

How to handle remote monitoring of log4j ?

I´ve been using chainsaw to remotely monitor an application that use log4j. I´m wondering if there are better ways to do it, or perhaps another logging framework. ...

Help getting image from Servlet to JSP page

I currently have to generate an image that displays the text of a string, i need to make this image on a Servlet and then somehow pass the image to a JSP page so that it can display it. I'm trying to avoid saving the image, and instead somehow stream the image to the JSP. I haven't found a way of generating the image since i started wit...