java

Objective-C. Can you use protocol like a Java interface?

Are these basically the same thing? For example if I have an interface in Java public interface CoolObject{ ... } I can use any object that implements the CoolObject interface in functions that take a CoolObject as a parameter: public void foo(CoolObject o) { ... } Is this the same in Objective-C? @protocol CoolProtocol ... @en...

Java: Form Submission in MVC : What is the best practice?

I am using a MVC framework which is a bit like struts. So, say I have a "Edit Store" link in my application this is how the url would look like: http://localhost:9080/test?action=editStore&storeNum=10 Now, action determines my Action (analogous to Struts Action) to be run. The corresponding action here is: EditStoreAction. Clicking...

What does the registerNatives() method do?

In java, what does the private static method registerNatives() of the Object class do? ...

Time-efficient Gameloop in J2ME

I've done a series of questions about J2ME Game developing, and in a recent one, Neil Coffey commented As a side issue-- do you REALLY want to do 100 ticks/second in a J2ME game? As I think sb has mentioned, you should really also sleep to the next desired wake-up point, not a fixed duration each time. For some reason, th...

Refresh Pivot Table with Apache POI

I'm currently working on a Java application that uses a template excel file that contains a pivot table. The template file also has a data sheet that seeds the pivot table. This data sheet is dynamically loaded in the java application through the Apache POI api. When I open the excel file I must refresh the Pivot table manually to ge...

Help with Project Euler #200?

Possible Duplicate: Need help solving Project Euler problem 200 Similar to this question Project Euler Problem 200. I wrote up a brute force solution in Java that takes several hours to run, and produced the first 500+ sqube numbers, which I thought should be enough. However, none of the answers from 190 to 210 seems to be...

Missed Socket Message

I have been doing socket programming for many years, but I have never had a missed message using TCP - until now. I have a java server and a client in C - both on the localhost. They are sending short message back and forth as strings, with some delays in between. I have one particular case where a message never arrives on the client...

Table Column Names - NetBeans IDE

Hi , I am using NetBeans to build a Desktop App. I'm using JavaDB as the database. I need a column named "Date" . However , I get an error whenever I try to name a column that. Any suggestions ? Thanks in advance . P.S I'm a newbie ...

Best way to create a hashmap of arraylist

I have one million rows of data in .txt format. the format is very simple. For each row: user1,value1 user2,value2 user3,value3 user1,value4 ... You know what I mean. For each user, it could appear many times, or appear only once (you never know). I need to find out all the values for each user. Because user may appear randomly, I u...

What experience do you have using nginx and memcached to optimize a web site?

We have a Java EE-based web application running on a Glassfish app server cluster. The incoming traffic will mainly be RESTful requests for XML-based representations of our application resources, but perhaps 5% of the traffic might be for JSON- or XHTML/CSS-based representations. We're now investigating load-balancing solutions to dist...

Adding files to java classpath at runtime.

Hi folks, Is it possible to add a file (not necessarily a jar file) to java classpath at runtime. Specifically, the file already is present in the classpath, what I want is whether I can add a modified copy of this file to the classpath. Thanks, ...

Faster alternatives to replace method in a Java String?

The fact that the replace method returns a string object rather than replacing the contents of a given string is a little obtuse (but understandable when you know that strings are immutable in Java). I am taking a major performance hit by using a deeply nested replace in some code. Is there something I can replace it with that would ma...

File reading and testable code

I have a piece of java code which reads strings from a file and creates a map out of the strings. As this code depends on a file, unit testing is clumsy. How does one design such pieces so that code can be unit tested? One approach that I can think of is, instead of this piece taking a file as an argument it can take an input stream. I...

How many hardware details can a Java Applet Discover?

I'm writing a Java applet to run differently under different hardware. For instance if I know a computer has a large amount of RAM but a weak processor, I can alter the balance of some time-memory trade-offs. Being able to discover the exact make and model of the CPU on which the applet is running could be helpful. Having such informatio...

How to bypass validation in dataTable? JSF.

I have table with two SelectOneMenu in row. I need populate data in second menu depending on the data that was selected in first. I need bypass validation phase because. I add rows to table dynamically. +-- Table ---------------------------------------------------+ | | | | Fi...

Line by Line Printing in Java

I want to print a page line by line on Dotmatrix Printer (Epson LQ-300 Printer).Which means, I will send a line of some text to printer and after a break I will send another, now both the lines should be on one page not on two pages. Please show me how I can achieve this. Regards. ...

How do you speed up java unit tests?

Currently our project has over 3000 unit tests, and "ant testAll" takes well over 20 minutes. besides getting better hardware, are there ways to speed things up? ...

Is there a builder based java api for selenium ?

Does anyone know of a builder-based alternative/supplement to the "classical" com.thoughtworks.selenium.Selenium interface ? It just seems like it'd be a much better approach for this api... ...

SystemTray for jdk 1.5

I am converting code from jdk 1.6 to jdk 1.5 and the code is: import java.awt.SystemTray; public static void main(String[] args) { if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); } try { tray.add(trayIcon); } catch (AWTException e) { System.err.println("TrayIcon could...

Get file name from a file location in Java

I have a String which provides an absolute path to a file (inlcuding the file name). I want to get just the filename. What is the easiest way to do this. It needs to be as general as possible as I cannot know in advance what the URL will be. I can't simply create a URL object and use getFile() - all though that would have been ideal if ...