java

accessing HttpServletRequest object in Spring WebFlow

I am using WebFlow and would like to add the current Locale into the flow. I already have a resolveLocale method that does this with this signature: public Locale resolveLocale (HttpServletRequest request); I would like to add something like this in my WebFlow XML: <on-start> <evaluate expression="localeService.resolveLocale(???)" r...

Java: Pick a random value from an enum?

If I have an enum like this: public enum Letter { A, B, C, //... } What is the best way to pick one randomly? It doesn't need to be production quality bulletproof, but a fairly even distribution would be nice. I could do something like this private Letter randomLetter() { int pick = new Random().nextInt(Letter.va...

Determining the source of a window activation event in Java

I am using the java WindowAdapter class to determine when a window is activated and then do some appropriate work. This is accomplished by implementing the windowActivated method of the WindowAdapter. Now, I am having some strange behavior and when I open one type of window it then activates another type afterwards. I tried to get a s...

Storing type information for a java code builder

So I have a a text file that looks something like this: public >ret method(>input ){ //do something with input . . . //return something of type >ret } I want to be able to type something like: HelloWorld is a method that prints "hello world" using nothing as input and returns nothing. The program does Hell...

Android - How to set a named method in button.setOnClickListener()

Most samples that I see appear to use an anonymous method in a call like button.setOnClickListener(). Instead, I'd like to pass in a method defined on the Activity class that I'm working in. What's the Java/Android equivalent of the following event handler wiring in C#? Button myButton = new Button(); myButton.Click += this.OnMyButton...

Compiling Hello World

I'm working from a simple "hello world" tutorial and then modify it into the app I want. I started out with a hello world app added a button and now I'm tryin to respond to button events, etc. But when I compile I'm getting the error: "package andriod.widget does not exist \n import andriod.widget.Button;" The code is package com.luk...

Running Shell scripts through java

So I have a java class that takes individual commands and puts them into the shell through the Runtime and Process objects. My problem is that I can run a command like: $ls /users/me/documents and it will work, but $cd /users/me/documents $ls still lists the root. Obviously the Process and runtime objects don't keep track of whe...

toString() unavailable error in Eclipse debugger

While stepping through a method using the Eclipse debugger, I started seeing "toString() unavailable - no suspended threads" for all the variables I wanted to inspect. Why did I get that error, and what should I do next to narrow down the problem in my code? edit My code does create a new process, but the variables I wanted to examine ...

Java specialist providing code review services

I was wondering if there are any specialist that do java source code review for companies (suggest improvement, etc). What would be a reasonable rate for someone, and what qualifications would they have? Any suggestions? ...

Java: Execute a method at a specified time interval

Hello I have this problem. I need to have a method repeated endlessly, if possible, but without overloading the system. As I understand, while(true) { ...code... } will hang the system. What would you suggest me to use which won't hang the system? Thanks Also: The execution of a my method may take up to 5 minutes, or 50 millisecond...

The trade-off that comes with using BigDecimal instead of double in Java.

I'm writing code for a neural network, and I'm wondering whether I should do it or not. I'm actually somewhat worried that even using double might not wield good results and that I might have to migrate my code to a more efficient language, like c++. I've read in a question here that BigDecimal is 1000 times slower than double? That's a ...

Which Eclipse version should I download?

I am on a Windows machine. Want to practise Java for the web using: Tomcat, Java, JSP's, Spring Framework, and Hibernate. http://www.eclipse.org/downloads/ (Silly question, but I am a newbie and don't want to get the wrong IDE version.) ...

What is a "Java Bean"?

The name really throws me off. I'm hoping someone can explain it in a way I won't forget :) ...

Bypassing the Hibernate cache in a transaction

I have a strange use case of Hibernate where in a call farther up a large stack needs an unmodified copy of an object that is part of a hibernate transaction. however, every time I ask Hibernate for a copy of the object, it's returning the version that's already been modified / is part of the transaction. Is there a way for me to force...

Drawing a dynamic graph

I have a web application written with JavaServer Faces technology. The application takes n inputs and provides an output. I want the following functionality in my application. I want to have sliders for each of my inputs. I want the output to be depicted by a graph. So whenever I change the input values via a slider I want the chang...

Check Java Object Hierarchy Externally

Say I have the string "Bar" and I want to know whether or not Bar is a valid object, and further, whether "Bar" extends "Foo". Would I be using Java reflection or is there a better way, like a database? and how would I do it? Cheers ...

How to clear the screen output of a Java HttpServletResponse

I'm writing to the browser window using servletResponse.getWriter().write(String). But how do I clear the text which was written previously by some other similar write call? ...

how do i make an exe in netbeans? (java program)

hi. anyone know how to create a .exe in netbeans? i've had a look around and i can make a jar but not an exe. ...

Richfaces scripts / styles not loading

I have a simple scrollableDataTable in a jsf <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <!-- RichFaces tag library declaration --> <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%> <f:view> <h:...

Eclipse RCP: Determine mouse button that caused selection on SelectionChanged Event.

I have a class that implements ISelectionListener. I want to determine when the user right clicked when the selection was made. This is the method that I need to implement to handle selection changes: public void selectionChanged(IWorkbenchPart part, ISelection selection) { //HOW? // if right clicked... do something // else .. do defa...