As the title says. How do you write (and run) a correct micro-benchmark in Java?
I'm looking here for code samples and comments illustrating various things to think about.
Example: Should the benchmark measure time/iteration or iterations/time, and why?
Near Duplicate of: http://stackoverflow.com/questions/410437/is-stopwatch-benchmar...
I'm working on a simple little swing component, and I'm tearing out my hair trying to figure out why my paint method isn't working.
The idea behind this component is that it's a small JPanel with a label. The background (behind the label) is supposed to be white, with a colored rectangle on the left-hand side indicating the ratio of two...
This question is self explanatory if you know how to use JMockit: How do I mock a method that has generics on it? I want to mock this method: public T save(T entity) but it always throws an exception like this:
mockit.RealMethodNotFoundForMockException: Corresponding real methods not found for the following mocks:
Object save(Object)
...
What is the difference between using a Set or a Collection for @OneToMany or @ManyToMany properties on my hibernate entity objects?
Does Hibernate map things differently depending on which one you choose?
...
You have usage:
http://mojo.codehaus.org/findbugs-maven-plugin/usage.html
<project>
[...]
<reporting>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<xmlOutput>true|false</xmlOutput>
<xmlOutput...
I've been looking through the ANTLR v3 documentation (and my trusty copy of "The Definitive ANTLR reference"), and I can't seem to find a clean way to implement escape sequences in string literals (I'm currently using the Java target). I had hoped to be able to do something like:
fragment
ESCAPE_SEQUENCE
: '\\' '\'' { setText("'")...
The title more or less sums it up. We use MS TFS as our version control which integrates to eclipse via the teamprise plug-in (Corp standard, primarily an MS shop. I wish we could just use SVN, because frankly the Teamprise plug-in is rather atrocious). Suppose that someone commits a file with changes that we want to keep, just not ye...
My boilerplate listener:
class MyMouseMotionListener implements MouseMotionListener {
public void mouseDragged(MouseEvent e) {
System.out.println("Dragged...");
}
public void mouseMoved(MouseEvent e) {
System.out.println("Moved...");
}}
Simple enough, but what do I add it to in order to listen to system-wide events? I've been resea...
Hello,
I’m trying to parse a XML file up to 500 mb in java. I tried to use SAX but it gives me this error
java.lang.OutOfMemoryError: Java heap space
at com.sun.org.apache.xerces.internal.util.XMLStringBuffer.append(Unknown Source)
Can you help me?
Thanks a lot.
P.S. Smaller XML files works just fine
...
So lets say I have this interface:
public interface IBox
{
public void setSize(int size);
public int getSize();
public int getArea();
//...and so on
}
And I have a class that implements it:
public class Rectangle implements IBox
{
private int size;
//Methods here
}
If I wanted to use the interface IBox, i can't act...
I have a SOAP service that exposes a method
TradeDetail getTradeDetail()
TradeDetail stores 5 fields, transaction number, dates etc
I need to add a couple of fields to TradeDetail. I want to keep backward compatibility (for a while) and it looks as if my options are limited to creating a new class with the extra fields
TradeDetail2 ...
I work for a large corporation that runs a lot of x86 based servers on which we run JVMs.
We have experimented successfully with VMWare ESX to get better usage out of our data center. But these still consume a lot of power per processing unit.
I had a mad idea that we should resurrect mainframes, we could host either lots of JVMs or v...
I'm trying to work out how to make SWT widgets (e.g. Label, Frame) be some shape other than rectangular.
I've made a custom shaped main window using the setRegion() method. Now I would like the widgets in the window to follow the same shape. I've tried using the setRegion() method on the widgets themselves (they inherit it) but nothing ...
eg:
Text:
<!-- Nav bar -->
<TD>
<A HREF="/home"><IMG SRC="/images/home.gif"></A>
<IMG SRC="/images/spacer.gif">
<A HREF="/search"><IMG SRC="/images/search.gif"></A>
<IMG SRC="/images/spacer.gif">
<A HREF="/help"><IMG SRC="/images/help.gif"></A>
</TD>
Regex:
(<[Aa]\s+[^>]+>\s*)?<[Ii][Mm][Gg]\s+[^>]+>(?(1)\s*</[Aa]>)
Resul...
I have an ArrayList a collection class of java as follows.
ArrayList<String>animals = new ArrayList<String>();
animals.add("bat");
animals.add("owl");
animals.add("bat");
animals.add("bat");
As you can see the animals ArrayList consists of 3 bat elements and one owl element. I was wondering if there is any API in collection framework ...
Hi everyone,
I was curious if anyone had any suggestions on a Java library that provides access to MSMQ? I've downloaded the trial of the J-Integra Java-COM library and have built and run their MSMQ example app, but I was curious if there were any good (free :)) alternatives. I've run across a few JNI implementations like jMSMQ and a f...
Hi,
We are using NTLM authentication using JCIFS in our web application. In the web.xml file, we are specifying the domain controller server name, like this:
<!-- NTLM code -->
<init-param>
<param-name>jcifs.http.domainController</param-name>
<param-value>SERVERNAME</param-value>
</init-param>
my question here is:
Is there ...
In Java is there a way to check the condition:
"Does this single character appear at all in string x"
without using a loop?
Thank you,
...
How to execute a java program with the help of Runtime.getRuntime().exec().
For example we shall have the java file path as c:/java/abc.java. Please help me with the code.
...
I'm interested in building a Texas Hold 'Em AI engine in Java. This is a long term project, one in which I plan to invest at least two years. I'm still at college, haven't build anything ambitious yet and wanting to tackle a problem that will hold my interest in the long term. I'm new to the field of AI. From my data structures class at ...