java

What IDE should I use for Java Graphics?

I have had 2 courses in Java programming. We only used a pico editor on a sun server. I am transferring schools but they asked me to cover several chapters on Java graphics before my Advanced Java classes this fall. What options do I have for free or cheep IDEs to use for Java graphics? ...

Apache HttpClient 4.0-beta2 httppost, how to add a referer?

I'm trying to add a referer to an http post in Apache HttpClient (httpclient-4.0-beta2). I found some sample code that does this. The code works, but I'm wondering if there is not a simpler, more straightforward way to add the referer than using the (ominously named) addRequestInterceptor, which appears to take an (yikes!) inner class a...

PMD rule DataflowAnomalyAnalysis oddness.

I have the following JUnit test: @Test public void testRunLocalhost() throws IOException, InterruptedException { // Start an AnnouncerThread final AnnouncerThread announcer = new AnnouncerThread(); announcer.start(); // Create the socket and listen on the right port. final DatagramSocket socket = new DatagramSocket(...

AspectJ vs. toString()

public pointcut myToString() : within(mypackage.*) String around(): myToString(){ System.out.println("myToString"); return proceed(); } It works only if I override toString in class Im trying to weave, is there any way to make it work on all toString methods? ...

Make two servers talk to each other

I have application written in GWT and hosted on Google AppEngine/Java. In this application user will have an option to upload video/audio/text file to the server. Those files could be big, up to 1gb or so and because GAE/J does not support large file I have to use another server to store those files. This would be easy to implement if th...

Uva's 3n+1 problem

I'm solving Uva's 3n+1 problem and I don't get why the judge is rejecting my answer. The time limit hasn't been exceeded and the all test cases I've tried have run correctly so far. import java.io.*; public class NewClass{ /** * @param args the command line arguments */ public static void main(String[] args) th...

Clean up repetitive setup and cleanup Java(JDBC) code

I've too many methods that repeatedly do something like Statement stmt = null; ResultSet rstmt = null; try { stmt = conn.createStatement(); rstmt = stmt.executeQuery(...); while (rstmt.next()) { //handle rows } } catch (SQLException e) { //handle errors } finally { try {rstmt.close();} catch (SQLException...

Java: Any simple way a function can return the calling class and method name?

Often I will send debugging info to my log file from within Java, and it helps to give decent information as to where in the code the log message was generated so I can quickly refer back to it. I don't want to hard-code anything in the log message about its location, because I have to remember to update the log message if I rename its ...

Can not access the Instance Data of a Singleton class from MBean

I am working against the deadline and i am sweating now. From past few days i have been working on a problem and now its the time to shout out. I have an application (let's call it "APP") and i have a "PerformanceStatistics" MBean written for APP. I also have a Singleton Data class (let's call it "SDATA") which provides some data for th...

JUnit expected tag not working as expected.

I have the following test case in eclipse, using JUnit 4 which is refusing to pass. What could be wrong? @Test(expected = IllegalArgumentException.class) public void testIAE() { throw new IllegalArgumentException(); } This exact testcase came about when trying to test my own code with the expected tag didn't work. I wanted to see ...

dom4j converting text to special characters

I'm using dom4j to parse my xml. Let's say I have something like this: <?xml version="1.0" encoding="UTF-8"?> <foo> <bar>&#402;</bar> </foo> When looking at the value of the "bar" node, it gives me back the special character as represented by "& #402;" Is there a way to prevent this and just read in the actual bit of text? ...

Intelligent ways to maintain versioned copies of tables in a relational database (programming considerations?)

Greetings, Just a bit of backgroung information - I am currently working on a relatively large desktop-based requirements management utility, and have come across an issue for which I believe I know the solution, but am hesitant to implement without further thought. Basically, at anytime during the usage of this requirements management...

Is there a set of stubs/mocks for JDBC available anywhere?

For the past few years I've continuously struggled with unit testing database code and all the pain that comes with it. I found this existing thread which I found very enlightening: What's the best strategy for unit testing databases? The author of the accepted answer suggests that it might be useful to mock the entire database layer...

Java Chat Server

I am writing a java based chat server and currently my design is based on following :- when a person in a chat room sends a message, the chatroom class at the server side, sends the same message to every participant in the room in a loop. Obviously , this is a poor design because networks calls are being made to individual participants i...

Java Header not displayed

i am inclduing a header.jsp in my layout.sp but it does not get reflected in the browser and have tried both mozilla and ie even after refreshing cache.. header.jsp content--- <h1>Login Application</h1> layout.jsp content-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-tr...

Architecture/Design of a pipeline-based system. How to improve this code?

I have a pipeline-based application that analyzes text in different languages (say, english and chinese). My goal is to have a system that can work on both languages, in a transparent way. NOTE: This question is long because it has many simple code snippets. The pipeline is composed of three components (lets call them A, B, and C), and ...

Is there a shortcut in Eclipse to Re-run the most recently launched program?

One of the most frequent thing I do with Eclipse is to re-run the last program. I do it by going to Run -> Run History -> [top most item]. Is there a shortcut key that does this? Edit: I know of CTRL+F11 but this does not work for me. It will launch the most recent program only if the currently active class (the class whose source code...

jdbc4 CommunicationsException

I have a machine running a java app talking to a mysql instance running on the same instance. the app uses jdbc4 drivers from mysql. I keep getting com.mysql.jdbc.exceptions.jdbc4.CommunicationsException at random times. Here is the whole message. Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.ex...

.Net vs Java Jobs

When I do a job search for a .Net developer it's all mostly the same stuff .Net, ASP, SQL Server, CSS, Javascript, AJAX, and maybe C#. Whereas with Java you may have to have Java, Sturts, Spring, JSF, EJB, a RDMB, Eclipse RCP, CSS, Javascript, AJAX, Rest, any number of specific Java APIs. Is it easier to be a .Net developer since the tec...

Integrating Maven reporting plugins

I need to setup Maven plugins. I have downloaded the JARs. Can anyone please tell me what do I do next in order to integrate or setup the plugins with Maven? Should I copy the JARs into the parent directory or do I need to edit any file? The plugins are: Java2HTML JDepend Checkstyle Clover Cobertura EMMA Findbugs JavaNCSS PMD QALab Xr...