java

directory structure to access .sh file from war

Hi All, I have a .sh file i am creating a war file wheter in the classes are under web-inf/classes/test/test.class .i am accessing .sh file from test class using the following syntax string cmd="./test.sh" runtime api i am not able to access this file if i place it under web-inf/classes .i want to know where can i place .s file in war ...

Tomcat--Web Server or Web Container?

Hi, I've a small doubt in my mind; could anyone please clarify me is the Tomcat web server or Web container? ...

doubt in java basics?

class test { test() { System.out.println("Constructor"); } { System.out.println("Hai"); } } public class sample { public static void main(String [] a) { test t = new test(); } } in the above code why is that the statement given within the braces ((i.e) "Hai") is Printed before the ...

Book for SCBCD exam

Hi friends, I'd like to know which is the best book for the preparation of SCBCD 5.0 exam? I've no experience in EJB developement, and I'm actually student. I've already cleared SCWCD and SCJP. Can I go for HF? Is there actually no book of Head First for SCBCD 5.0 preparation? ...

Dynamically converting java object of Object class to a given class when class name is known

Yeah, I know. Long title of question... So I have class name in string. I'm dynamically creating object of that class in this way: String className = "com.package.MyClass"; Class c = Class.forName(className); Object obj = c.newInstance(); How I can dynamically convert that obj to MyClass object? I can't write this way: MyClass m...

Lucene searching by numeric values

I'm building a Java Lucene-based search system that, on addition, adds a certain number of meta-fields, one of which is a sourceId field, which denotes where the entry came from. I'm now trying to retrieve all documents from a particular source, but the index doesn't appear to be able to find them. However, if I search for a wildcard va...

Java wysiwyg HTML Editor

Hello, I'm working on a project and need a simple free java HTML wysiwyg editor can anyone point me in the right direction?. It only has a small space to fit into, so something fairly simple would be best. Thanks for the help! ...

Java graphics performance

I was programming a simple game and wanted to display it via the Java Graphics + Swing API. It felt a little slow, of course, so I measured how long it took to repaint, which was around 32ms. Then I read about accelerated Java graphics and used the method described here: Space Invaders However, somehow this is even slower. It now takes ...

How do I put the entire lib directory (including all subdirectories) on the classpath using Ant?

I'm not sure this is the problem, but it looks like it might be the case. I'm getting build errors telling me that certain packages don't exist. These packages are packages that exist in .jar files within my lib directory. Any other packages within my java source files that I'm compiling and copying to the classes directory are working j...

stack overflow in swing at processKeyEvent

Hi, I'm battling an error I don't quite understand. I have a class in Java, let's call it DownloadTable derived from a JDTable. Each of these classes implement KeyListener. I'd like the base class JDTable to handle some keystrokes, so I put this.AddListener(this) in its constructor and create a key handler public void keyPressed(K...

Is it possible to call a method using a variable?

In PHP (for example), you can use this way to call a function using a variable like this: $funcname = "print"; $funcname("Whatever..."); // Same as: print("Whatever..."); What is the way used in Java? ...

Why should I avoid using Java Label Statements?

Everywhere across the internet people say that you should avoid using label statements in java. However, I find them very useful in some cases, namely nested loops. I cannot find satisfactory answers as to why not to use them. I think that alternatives to labels often reduce either readability, or performance, or both. So what makes lab...

Maven GWT 2.0 and Eclipse

Does anyone know of a good guide for creating a project with the new 2.0 release of GWT using maven and eclipse? I am running into a lot of problems getting them to play nicely together. For what it's worth, I can create a gwt project using the maven eclipse plugin which works fine, but porting it to maven doesn't work (so a guide for ...

Sort one column of data in a csv file in ascending order in java

import java.io.*; import java.util.*; public class Sort { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new FileReader("data1.csv")); Map<String, String> map=new TreeMap<String, String>(); String line=""; while((line=reader.readLine())!=null){ map.put(getF...

What is the easiest way to sort maps according to values in Java?

I want my hash to sort in descending order according to the values. How do I do that in Java? ...

How to package Factories in Java

Hi Guys, I was wondering how to package the factories I have in my application. Should the Factory be in the same pacakage as the classes that use it, in the same package as the objects it creates or in its own package? Thanks for yout time and feedback ...

Is null an Object?

Is null an Object in Java? ...

Standards for using inner classes for GUI?

Hi, I'm wondering about the standard practice with inner classes (in Java but I suppose it applies to all OO languages). So I have a JFrame subclass ControllerWindow that contains a JPanel subclass MapPanel which I draw onto (so it needs to overwrite paintComponent method) and which needs to implement a mouse listener. My current solutio...

J2me implentation for linux or other

Hi, I'm searching for information on how to create a j2me implementation. My target is a generic linux host... does it exist already? I mean a way to run j2me applications on linux without an emulator? Do you know where to find info? ...

Understanding the workings of equals and hashCode in a HashMap

I have this test code: import java.util.*; class MapEQ { public static void main(String[] args) { Map<ToDos, String> m = new HashMap<ToDos, String>(); ToDos t1 = new ToDos("Monday"); ToDos t2 = new ToDos("Monday"); ToDos t3 = new ToDos("Tuesday"); m.put(t1, "doLaundry"); m.put(t2, "payBills"); m.put(t3, "cleanAt...