java

How do you see the future of .NET versus JAVA?

For last couple of years it seemed like .NET was gaining a lot of ground, there were articles out there predicting that .NET eventually will "outdo" Java, but lately it seems like the .NET hype kind of slowed down as Java is still going strong (maybe it's only me who sees it that way). How do you see these 2 technologies in the future? ...

Mapping of strings to integers

What is the easiest way in Java to map strings (Java String) to (positive) integers (Java int), so that equal strings map to equal integers, and different strings map to different integers? So, similar to hashCode() but different strings are required to produce different integers. So, in a sense, it would be a hasCode() without the c...

Converting MySql DateTime type into something more friendly

I have a Java web app that reads a MySql db and returns DateTime fields. What is the best way to convert the DateTime fields returned in the resultset into something more readable? Currently the DateTime fields print as: 2008-12-14 16:30:00 but I would like something more user friendly like: 14 Dec 2008 at 16:30 I am populating an ...

Oracle SQL DATE conversion problem using iBATIS via Java JDBC

I'm currently wrestling with an Oracle sql DATE conversion problem using iBATIS from Java. Am using the Oracle JDBC thin driver ojdbc14 version 10.2.0.4.0. iBATIS version 2.3.2. Java 1.6.0_10-rc2-b32. The problem revolves around a column of DATE type that is being returned by this snippet of SQL: SELECT * FROM TABLE(pk_invoice_qry...

For learning OO, do you recommend Head First Java or Head First OOA&D?

I learned some C on my own and I've finished one semester of Java programming. OO programming takes a different approach to problems. I want to know which book will help me pick up the OO aspects of Java. So I've looked through Stack Overflow and two books have come up several times: Head First Java and Head First Object Oriented Anal...

Question about the Java Garbage Collector, nulls and memory leaking.

Suppose I'm implementing a queue in java and I have a reference to the initial node, called ini and another to the last one, called last. Now, I start inserting objects into the queue. At one point, I decide I want an operation to clear the queue. Then I do this: ini = null; last = null; Am I leaking memory? The nodes between ini and ...

What is the easiest alternative to a generic array in Java?

Suppose I have this: class test<T> { private T[] elements; private int size; public test(int size) { this.size = size; elements = new T[this.size]; } } It seems this isn't possible because the compiler doesn't know what constructor to call once it tries to replace the generics code or something. Wha...

What is the best library for Java to grid/cluster-enable your application?

This is the ability to run your application on a cluster of servers with the intent to distribute the load and also provide additional redundancy. I've seen a presentation for GridGain and I was very impressed with it. Know of any others? ...

Where should I start drawing? (Java,GUI)

I have the points by the end of the GenerateButton class but now that I got my public double[][] matrix with all the points in, where do I begin drawing them??? my Main.java: import java.awt.*; import javax.swing.*; public class Main { public static Display display = new Display(); public static void main(String[] args) { ...

Can the eclipse formatter be used stand-alone

Is there a way to use the formatter that comes with eclipse, outside of eclipse? I would like to format some java files using my formatter.xml file that I have configured using eclipse. Does anyone have any code examples that would allow me to do this? I would also like to use this standalone, so the specific jars that are used would ...

How do I make a Java ResultSet available in my jsp?

I'd like to swap out an sql:query for some Java code that builds a complex query with several parameters. The current sql is a simple select. <sql:query var="result" dataSource="${dSource}" sql="select * from TABLE "> </sql:query> How do I take my Java ResultSet (ie. rs = stmt.executeQuery(sql);) and make the results availa...

Tracking memory usage in a tomcat webapp

Are there any good tools available to track memory usage In a tomcat java webapp? I'm looking for something that can give a breakdown by class or package. Thanks, J ...

Limit Access To a Spring MVC Controller -- N sessions at a time

We've licensed a commercial product (product not important in this context), which is limited by the number of concurrent users. Users access this product by going through a Spring Controller. We have N licenses for this product, and if N+1 users access it, they get a nasty error message about needing to buy more licenses. I want to m...

Java/JSP Image upload. Where to keep these image files?

Hi everyone, I am writing a simple application that let user upload images. After the upload the user can tag them or remove them. Nothing fancy nothing special. So I figured out how to upload the files and save them once the files are uploaded. I am keeping tracking of a global path where images are kept. In the database i keep the m...

Maven replacement?

What would you suggest as a replacement to the Maven Java build toolset? Just plain Ant scripts? SCons? ...

How to configure JPA for testing in Maven

Is there a way to set up a second persistence.xml file in a Maven project such that it is used for testing instead of the normal one that is used for deployment? I tried putting a persistence.xml into src/test/resources/META-INF, which gets copied into target/test-classes/META-INF, but it seems target/classes/META-INF (the copy from the...

How does Java pick which overloaded function to call?

This is a purely theoretical question. Given three simple classes: class Base { } class Sub extends Base { } class SubSub extends Sub { } And a function meant to operate on these classes: public static void doSomething(Base b) { System.out.println("BASE CALLED"); } public static void doSomething(Sub b) { System.out.println...

Java: In what order are the methods called in an Applet?

Of all these methods what's being run and in what order?? I guess the first question to ask is whats being run first? And why does th.start() start run()? import java.applet.*; import java.awt.*; import javax.swing.JFrame; public class BallApplet extends Applet implements Runnable { int x_pos = 10; int y_pos = 100; int ra...

Java Client to connect to Server with Openssl and Client Auth.

I have to write a Java Client to connect to an SSL server. The server uses openssl certificate, and is configured to do Client Auth. I can't seem to locate any useful resources online that can help me (who doesn't know anything about openssl and much about SSL) to understand who to go about implementing my Client Side. Help! ...

Why wasn't the Java "throws" clause (in method declaration) included in C#?

Why wasn't the Java "throws" clause (in method declaration) included in C#? ...