java

Designing mvc controller layer

Hi, I am trying to understand and practice the MVC-pattern to improve my development. So I started refactoring an application I once wrote and have progressed so far. It is completely clear how my model looks like and also the view is ready so far. But now I am searching for a good practice to design my controller layer. I have created a...

How do I compare two Integers?

This sounds like a stupid question, but I'm kinda stuck here. I have to compare two Integer (not int). How do I compare them? Integer x = ... Integer y = ... I can think of this: if (x == y) The == operator only compares references, so this will only work for lower integer values. But perhaps auto-boxing kicks in...? if (x.equals...

Repairing Code Number with missing digits

I have recently been reading about Error Correction for a job interview and have written a number of programs that use n-ary BCH (Bose, Chaudhuri, Hocquenghem) cyclic codes and have now written a script that will generate phone numbers once given an "area code" for a given user (encoding) and will decode it and will repair up to two erro...

How to justify using a scripting language as part of a project

I have a specific project in which I want to use either a scripting language + C, or as an alternative a 100% Java solution. The program adapts a legacy system for use with other moderns systems. Basically, I have few choices as to what language I can use. I have C/C++, Java 1.4, and I have also compiled the Lua for this environment. ...

Can't find a public symbol variable on one instance of a class (Java)

I am writing a program to calculate the shortest path between two nodes. In my program I have one custom class called NodeList, which contains an ArrayList of strings (representing nodes) along with a distance. I am using Dijkstra's algorithm which involves opening up the shortest edge from each node. So, I use this loop to tabulate the ...

Is it possible to have the System ClassLoader load .class files specified at run time?

I am writing a static analysis tool for an assignment, it analyses Java bytecode using the ASM library. One of the parts of ASM that we use requires (or at least, appears to require) that the class be loaded from the ClassLoader. We were hoping the tool would be able to analyse .class files without requiring them on the classpath. We al...

why we need to restart tomcat server when a class file is changed,is there no other way?

why we need to restart tomcat server when a class file is changed,is there no other way? ...

Using css in a StringTemplate Email

Hi, I'm currently using StringTemplate to create my emails on the fly and its proven very easy to use in creation of the email. However, I'm trying to apply some styling to my emails and dont seem able to do this in the normal manner. I can style parts of the mail if I write it inline, eg. <p style="color:red;">Hello again, $name$ !</...

encoding/decoding string and a special character to byte array

Hi I had a requirement of encoding a 3 character string(always alphabets) into a 2 byte[] array of 2 integers. This was to be done to save space and performance reasons. Now the requirement has changed a bit. The String will be of variable length. It will either be of length 3 (as it is above) or will be of length 4 and will have 1 spe...

basic I/O question

What is the difference between Reader and InputStream? Or in other words,what is difference between "the stream of bytes" and "the stream of characters"? I wonder when I should use InputStream or Reader otherwise,Could you suggest the material to me for understanding the question by myself? ...

spring: add xml context on-the-fly?

I'd like to be able to load spring context.xml files on-the-fly, so that they are wired with previously loaded contexts (meaning, in contextA.xml I can ref a bean defined in contextB.xml which was already loaded). I would like for existing beans to not be destroyed and then created whenever a context is added. ...

NetBeans / Java Launch Error

Hello, When I launch NetBeans (version 6.7.1) I get an error: http://78.46.92.11/errors/netbeans-launch-error.jpg It is the first time when I see it. I haven't had problems like this one before. It's the first time when I open NB and see such error. Also, when I try to open a project I get another error: http://78.46.92.11/errors/ne...

[Java] new Date(2009, 12, 9) is deprecated

What Can I used to replace this ? Thanks for your help ...

Design by contract and class invariant

hi I'm reading about dbc (http://en.wikipedia.org/wiki/Design%5Fby%5Fcontract) Can someone please give me a simple example of using class invariants in relation to inheritance? ...

HttpUnit with GAE

Hi, I am trying to tweak HttpUnit 1.7.2 to run under GAE, and stumbled accross the URLStreamHandler error. As HttpUnit uses URLStreamHandler to process javascript and https, removing URLStreamHandler means I can only access plain html website. How do I use GAE UrlFetch service to replace URLStreamHandler ? ...

Pure Java app on Glassfish?

I may be barking up the wrong tree here -- it's relatively easy to wrap a vanilla Java app in a daemon/service -- but it'd be really helpful for deployment if we could push pure Java apps onto a Glassfish server and have them start up automatically. We use JMS to connect this app to several other beans living on the Glassfish server. We...

How do I keep Eclipse from automatically deleting my exe file

I use Eclipse for Java development. There is an *.exe file in a subdirectory of my workspace, which keeps getting deleted. Specifically, one of the projects is dedicated to C++ development using MSVC; there is no Java there. The root of this project has cpp and h files, and I use MSVC to generate the exe under the /bin directory. A...

JSP pass Variable

Hi guys! I have to write a website with JSP and Servlets which displays a questionnaire and gets the result of the user. I've already written the question object, a questionnaire (random list of questions) and the questions library. Now my Servlet generates an instance of the questionnaire and displays the questions. My problem is I d...

profiling a web start application

There are a lot of java profilers out there, any recommendations as to what would be best for profiling a java web start application that is being deployed to glassfish inside a war? ...

Moving from state to state in this automaton via HashMap

I'm using this method to move from a state to the next on this automaton simulator: public void processString (String string){ StringBuilder stepString= new StringBuilder (string); int actualStateIntIndex; System.out.println("THE FOUND INITIAL ONE IS "+ theInitialStateIntIndex); State firstState = allStates.get(theInitial...