java

Java vs. C#, what are the advantages and disadvantages, for a web application.

I have heard that they are mainly similar and competing technologies, and it is mostly an issue of skill and manpower availability. Do you agree or are there technological differences in: Performance Ease of development Open source components availabilty Tools availability Community support Hardware/Software compatibility Other factors...

Convert from enum ordinal to enum type

Hi, I've an enum type: ReportTypeEnum that get passed between methods in all my classes but I then need to pass this on the URL so I use the ordinal method to get the int value. After I get it in my other JSP page I need to convert it to back to an ReportTypeEnum so that I can continue passing it. How can I convert ordinal to the Rep...

Java SWT: How to indicate a menu item is selected

Using SWT, what is the common way to indicate that a menu item (from a taskbar menu) is the currently active selection? Checkmark? Bold? How is this done with code? ...

problem while running shell script using java

Hi, I have a shell script named test.sh in /tmp/padm folder. In that shell script I have a single statement echo "good" I am trying to run the shell script using Java code. String cmd=("/tmp/padm/.test.sh"); Runtime rt = Runtime.getRuntime(); Process pr=rt.exec(cmd); But my problem is that I am not able to see "good" w...

How to create a photo gallery with slideshow effect of the images placed in server folder using jsp/servlet/javascript

I need to create slideshow of the images which are in server.These images would be changing as the user uploads. I need this using jsp/javascript/servlet/ajax ...

Retrieving expired objects in Ehcache

I'd like to implement the following algorythm above Ehcache : try to get an element from the cache if the element is not expired serve the value else serve the expired value refresh the element in the background But I never get an expired element (Element.isExpired()). I tried to play with my cache configuration (especially TimeT...

Java: What, if anything, is locked by synchronized methods apart from the object they belong to?

Now, I'm not sure whether this is a stupid question, please bear with me if it is. Is the lock on an object "recursive", i. e. if two objects have references to a third object in their fields and a thread is running a synchronized method on one of the two, can any other thread access the third object? // a and b are some objects that i...

JSP vs Velocity what is better?

What is better between JSP and velocity in - Performance - Ease of use - Ease of creating reusable components - Availability of open source 3rd parties - IDE support ...

The art of programming: Java vs C#

Throughout my university career I used Java to code projects until I started working which is where I had to delve into the C# realm. Though the .Net library is fairly extensive I can't help but feel that there is something missing in C# as compared to Java. I would like to know if Java is any better than C# or vice versa from the expert...

Comparing struts ognl value to scriptlet value in JSP

I have to compare this to a value like below: ${page_id } ---- <% out.print(a); %> <c:if test="${page_id != a}"> How can I do this? ...

How to replace a plus character using Java's String.replaceAll method

What's the correct regex for a plus character (+) as the first argument (i.e. the string to replace) to Java's replaceAll method in the String class? I can't get the syntax right. ...

Multiple Java projects and refactoring

I have recently joined a project that is usiing multiple different projects. A lot of these projects are depending on each other, using JAR files of the other project included in a library, so anytime you change one project, you have to then know which other projest use it and update them too. I would like to make this much easier, and w...

Eclipse Maven Plugin fails to create groovy-maven-archetype project

I have installed the Maven for Eclipse plugin from Sonatype. (update site: http://m2eclipse.sonatype.org/update/) I am creating a Maven project, and choosing to use the groovy-maven-archetype as my starting point. However, halfway through, I am seeing: 04/03/09 12:52:28 GMT: [FATAL ERROR] org.codehaus.mojo.groovy.stubgen.GenerateStu...

Why isn't calling a static method by way of an instance an error for the Java compiler?

I'm sure you all know the behaviour I mean - code such as: Thread thread = new Thread(); int activeCount = thread.activeCount(); provokes a compiler warning. Why isn't it an error? EDIT: To be clear: question has nothing to do with Threads. I realise Thread examples are often given when discussing this because of the potential to ...

IndexOutOfBoundsException when trying to read MS Excel file using Apache POI-HSSF

Whilst trying to parse MS Excel file using POI-HSSF v3.2 I am getting IndexOutOfBoundsException. The spreadsheet I am trying to read isn't empty it has been created using MS Excel 2003 and BiffViewer included with the POI package has no problem parsing it. My code is as follows: package src; import java.io.*; import org.apache.poi.hss...

Is there something like CherryPy or Cerise in the Java world?

CherryPy and Cerise are two small frameworks that implement nothing but the barebones of a web-framework and I love their simplicity: in fact I reckon that if Classic ASP was implemented that way (and didn't pretty much require VBScript) I could have settled for it and lived happily ever after. But now I'm living at the borders of the J...

Is there a java implementation of the ActiveRecord pattern that is built on top of Hibernate, similar to Castle Windsor?

I am looking for a Java implementationation of the ActiveRecord pattern which is built on top of Hibernate. In .Net there is a open source project Castle Windsor ActiveRecord which implements the ActiveRecord pattern on top of NHibernate. I'm looking for something like this, except sitting on top of the NHiberate persistence frameowork...

SQL: Batching statements with bound variables.

I'm looking to reduce the round-trips in my application to improve performance. I want to use PreparedStatements for their multitude of benefits. This is an example of what I've come up with.. generalized with details elided.. Class.forName( "..Driver" ); Connection connection = DriverManager.getConnection( .. ); PreparedS...

Best way to check whether a certain exception type was the cause (of a cause, etc ...) in a nested exception?

I am writing some JUnit tests that verify that an exception of type MyCustomException is thrown. However, this exception is wrapped in other exceptions a number of times, e.g. in an InvocationTargetException, which in turn is wrapped in a RuntimeException. What's the best way to determine whether MyCustomException somehow caused the exc...

What is build automation software (for example, Ant)?

I see reference of ant a lot but I don't get exactly what its meant to do? from what i've heard its supposed to compile your projects but can't i just do that by clicking Run->Run in eclipse? Edit : I guess I should rephrase my question. I already know that ant is a 'build automation software', my question is, what exactly is build auto...