java

Performing unbiased program/script performance comparison

I want to perform a comparison of multiple implementations of basically the same algorithm, written in Java, C++ and Python, the latter executed using Pypy, Jython and CPython on a Mac OS X 10.6.4 Macbook Pro with normal (non-SSD) HDD. It's a "decode a stream of data from a file" type of algorithm, where the relevant measurement is tota...

Pointer deferencing and manipulating objects which are being pointed to - equivalent constructs in Java

Hello In C++ you can do the following: int x = 5 cout << x; // prints 5 int* px = &x; (*px)++; cout <<x; // prints 6 Is there an equivalent construct in Java ...

problem in password validation

I am facing trouble in doing password validation. I am taking the min and max value for the range of password from the java class called applicationconstants and calling that in the servlets. I am using the validation function in another java class and calling that in servlet. Please help me in solving this problem. servlet code int mi...

How to cascade delete an entry without cascading into ManyToMany relations

Hello, I have a piece of code that 'updates' an entry in the database by first cascade deleting it, and then replacing it with a new object, because I had a lot of problems trying to update it normally. This hack worked fine, until I started using some ManyToMany relations. This is the relation that is giving problems: @ManyToMany(casca...

When designing something in OO..

..where do you begin? As a basis for any design - for instance a package - where do you as a developer start. I start by mapping out the requirements and breaking them down into sub categories and from this objects and methods. Usually takes a while before I start drawing it out by hand - then that goes through a few versions. But I a...

Most efficient way to make the first character of a String lower case?

Given an input String, what is the most efficient way to make just the first character lower case? I can think of a number of ways to do this. For example, using charAt and subString: String string= "SomeInputString"; string = Character.toLowerCase( string.charAt(0)) + (string.length() > 1 ? string.substring(1) : ""); Or using a ch...

How Java-Feature multithreading returning result ?

I am still learning about using Future and Callable in Java. Stumble into this question: Say I have class: TaskWorker implements Callable { public String id; public TaskWorker(String id) { this.id = id; } public Documents call() trows Exception { //Assume here, that Search and Doc are my own method to search and re...

Why datasource is not found in JNDI after injection from jndi.properties?

This is my persistence.xml: <persistence> <persistence-unit name="MyUnit"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>jdbc/abcDS</jta-data-source> </persistence-unit> </persistence> This is jndi.properties file from src/test/resources which is supposed to create a datasource during testing...

Using TinyMCE and filemanager to upload/handle files on java platform

I'm using TinyMCE ( http://tinymce.moxiecode.com/index.php ) as an editor on a webproject running on a Java-platform (Tomcat, Spring) There's a filemanager on the webpage for TinyMCE: http://tinymce.moxiecode.com/plugins_filemanager.php But as stated on that page: "The MCFileManager is a online file management utility, available as PHP...

JTextArea Real Time Spell Checker

I need a good spell checker library for Java that can spell check a JTextArea (or any JTextComponent) in real time. That is, it should have a wavy red underline appear under text while the user is typing. It needs to be able to list all the available word replacements by left clicking (yes, left clicking) the word. If not possible, ri...

Custom Marshalling from Java to Flex via BlazeDS

My team are putting together a proof-of-concept Flex application sitting on top of a Spring-based server using BlazeDS. We do quite a lot of date calculations, so we use Joda Time extensively throughout the code and in our domain model. We're now trying to figure out how we can continue to use Joda Time in our DTOs that are sent back-a...

How to store authentication credentials for legacy systems in a J2EE container?

I need to store authentication credentials for legacy systems in a J2EE container (IBM WebSphere Application Server Network Deployment 6.1). These legacy systems are accessed using an HTTP interface, but it's not a Web Service. The idea is to query these credentials using JNDI (or some other mechanism) and then use it to authenticate in ...

Splitting objects into their most fundamental parts..

Not sure if the title captures what I'm trying to say here. When designing in OO should I be splitting my objects up into their most specific areas - so if I have a factory object that deals with creating objects but later on i come across a way of creating objects for another purpose even though they may be the same objects is it worth...

how to handle bad file selection for image display in swing

I am learning Swing and wrote an app that lets user select an image file and displays it on a JPanel. It works, but I want to handle situations when user doesn't select any file user selects a non image file In these cases I want to clear the JPanel and show an error message on a text area. I tried to do this as below.But I am not s...

Working with part of a query at a time

I have a hibernate query which returns 10s of thousands of object results. Is it possible to cycle through chunks of the query rather than handling the entire query at once? Sample code: Query q = session.createQuery("FROM Class"); List<Class> classList = (List<Class>) q.list(); Thanks ...

Using JSP with Embedded Jetty 7 in Eclipse IDE, getting LogConfigurationException

I've included all jars the application requires, I'm trying to use Jetty Embedded I have a simple java class with a main method that has the following setup, servlets still work correctly just can't get JSP's to work. All required jars are included, started with basic Jetty jars then added all from the jsp folder. Server server = new ...

maintain session/connection between php and java app

A) If I have a java application which starts up and waits for socket connections on a specified port. Is there a way i could maintain a session connection in php after a user validates, i.e a persistent connection? B) I mean, I'm trying to understand how its done with mysql and php. How does mysql or php know what the last opened connec...

Beginning Java Web services. Where to start

Hi guys, my company runs a site that primarily has its backend logic coded in Perl. It works fine but ultimately we are headed to something Java driven. I do plan on studying this and would like to start setting up a Java environment on another server in our company so when the time comes I at least have a headstart. Does anyone have a r...

eclipse: running multiple launch configurations at once

hello, i have a several launch configurations in eclipse each launching the same java-program but with different parameters. now is it possible to run all of these at once (with one mouseclick) instead of selecting each of it seperately and launching it? thanks! ...

How to make JTable cells default to overwrite mode

JTable cells by default are in append mode when the cell is double clicked on. Is there a way to make the cell default to overwrite mode instead, IOW, select the contents of the cell so that if the user started typing the old text would be replaced by the new text without having to manually erase it? ...