java

JUnit 4: Set up things in a test suite before tests are run (like a test's @BeforeClass method, just for a test suite)

I want to do some functional testing on a (restful) webservice. The testsuite contains a bunch of test cases, each of which performs a couple of HTTP requests on the webservice. Naturally, the webservice has to run or the tests will fail. :-) Starting the webservice takes a couple of minutes (it does some heavy data lifting), so I want...

Best reflection of extract-interface refactoring in subversion

I'm extracting an interface that I would like to retain the original name. The actual class will get a "Impl" suffix, in accordance with our naming conventions. I want to know how to best reflect that in subversion so that the history "AppPropertiesImpl.java" covers its life as "AppProperties.java". As for the new "AppProperties.java", I...

Toplink Objects not showing up under the Toplink Map node in JDeveloper

Hello, for some reason I cannot see any of the generated objects under the TL Map. See the included image (Sorry but it will not render using the community wiki software.... http://img261.imageshack.us/my.php?image=nothingundernodetn5.png ...

Understanding imported WAR in Eclipse and its folder structure

Hi, I have just imported a WAR file from an external site, which is basically a servlet into Eclipse IDE (the project runs on Apache-Tomcat). When I import it it has a folder called Web App Libraries. So here are a few of my newbie questions: I am unsure about what the exact purpose is of this folder is? What does it do, why would...

Cross-platform executable/runtime delivery method

I need assistance finding a delivery method that best fulfills the following requirements: We wish to deliver a single file to my clients. Clients should be able to launch this file from the operating system shell - much like running an '.exe' on Windows. After being launched, the program/script should be able to display a window with ...

Java equivalent of std::deque

I'm a relatively new Java programmer coming from C++/STL, and am looking for a class with these characteristics (which the C++ std::deque has, as I understand it): O(1) performance for insertion/removal at the beginning/end O(1) performance for lookup by index are growable collections (don't need fixed size bounds) Is there a Java eq...

Lib to protect SQL/javascript injection for java/jsp

Anyone know a good lib where i can run the strings before they are inserted, that can strip out sql/javascript code? To be run in jsp pages. Idealy the lib would be: Free Lightweight Easy to use Thanks in advance to the SO community who will happily reply :) ...

What is hard in Java but easy in Scheme?

These two languages are very different. They're each well-suited to their own particular tasks. What tasks are easy to do in Scheme, yet are hard / require lots of ugly code to do in Java? Another way of putting it: what is Scheme better at? If you can think of things that Java is better at, see this question. ...

What is hard in Scheme but easy in Java?

These two languages are very different. They're each well-suited to their own particular tasks. What tasks are easy to do in Java, yet are hard / require lots of ugly code to do in Scheme? Another way of putting it: what is Java better at? If you can think of things that Scheme is better at, see this question. EDIT: This pair of questi...

Eclipse Custom Variable for Java Code Templates

How do you add a new variable to be inserted into a Java code template. How do I add a variable to the list in Window->Preferences->Java->Code Style->Code Templates->Code->New Java Files->Edit->Insert Variable... ? Currently my new files get created with: ${filecomment} ${package_declaration} ${typecomment} ${type_declaration} I'd li...

How can I read other parameters in a multipart form with Apache Commons

I have a file upload form that is being posted back to a servlet (using multipart/form-data encoding). In the servlet, I am trying to use Apache Commons to handle the upload. However, I also have some other fields in the form that are just plain fields. How can I read those parameters from the request? For example, in my servlet, I ...

Proper synchronization of Java threads using wait/notifyAll?

Here is a simplified version of my application showing what I'm doing. /* in my app's main(): Runner run = new Runner(); run.dowork(); */ class Runner { private int totalWorkers = 2; private int workersDone = 0; public synchronized void workerDone() { workersDone++; notifyAll(); } public synchronized void dowork() { ...

Timing out tests in TestNG

Thanks to a library upgrade (easymock 2.2 -> 2.4), we're having tests that have started locking up. I'd like to have a time out on individual tests, all of them. The idea is to identify the locked up tests - we're currently guessing - and fix them. Is this possible, preferably on a suite-wide level? We have 400 tests, doing this each me...

Switching from GUI to Command Prompt in Java?

My professor assigned a project where a simulation is ran through a GUI. To edit it, we need to create a "New" menu item. We haven't learned how to get data from a GUI, and our book does not cover it at all. What I'm trying to do, is when the "New" command is hit, focus gets shifted back to the CMD prompt, where System.out. starts work...

creating immutable objects in JSPs

Hi, I know you can use the <jsp:useBean> tag to instantiate objects within JSPs without resorting to scriptlet code. However I'd like to instantiate an Integer who value is the result of an EL expression, something like: <jsp:useBean id="total" class="java.lang.Integer"> <jsp:setProperty name="amount" value="${param1 + param2}"/> <...

Bad idea to chain exceptions with RMI?

Is it a bad idea to use exception chaining when throwing RemoteExceptions? We have an RMI server that does something like this: public Object doSomething() throws RemoteException { try { return getData(); } catch (CustomException ex) { throw new RemoteException(ex); } } I'm getting UnmarshallEx...

Best source code formatter for Javascript?

I've been digging through Stack Overflow as well as a number of Google searches, and I cannot find a satisfactory code formatter for Javascript. I have found several related tools, such as syntax highlighters and pretty-printers, but I am looking for a tool that I can ideally create a wrapper for in Eclipse and simply run from the menu ...

How abstracted should MVC models be?

I'm in the process of extending and improving a website that has quite a few structural problems. It looks very much like the developers before me had heard of MVC but didn't understand the ideas of abstraction or modularity. So the MVC "framework" is a) bespoke b) broken c) patched and d) there are several in use all at once. I intend t...

System.currentTimeMillis vs System.nanoTime

Accuracy Vs. Precision What I would like to know is whether I should use System.currentTimeMillis() or System.nanoTime() when updating my object's positions in my game? Their change in movement is directly proportional to the elapsed time since the last call and I want to be as precise as possible. I've read that there are some seriou...

Understanding the the Sun JVM

Hi Guys I'm looking for some useful looks for a beginner who wants to better understand the Sun JVM Thanks ...