java

How to sort XML elements in Java?

I am trying to sort XML documents according to their nodes. What is an efficient sorting method? ...

Having problem with Try-Catch block in a Java I/O program.

I have created the output for a program that allows a user to input their employee name and number and then their hourly wage and their total number of regular hours and overtime hours. This is my first time working with this type of program in java and I'm having an issue with the Try-Catch block where it gets the text input from the us...

How to avoid FileNotFound exception when running Java on Linux because of case sensitiveness?

My web application runs on Windows. I would like to run my app on Linux also. I seem to have overcome most of the problems such as path separator, etc. Real problem now is I get FileNotFoundException when the Java code tries to open a file say Abc.txt when only abc.txt exists. :( I can't go on changing all the filenames to lowercase o...

Generics and Class.forName

Hi, I would like to create an instance of a specified class using its name. My code is shown below. I get a compiler warning. Am I doing this the right way? Is it even possible to use the name of a class and get an instance of that type back, as I don't think there is any way of the compiler knowing what the type should be? public sta...

How to configure routing for a java web app

Is there an easy way to rout all requests (except a few specific cases) for url "mysite/" to path "mysite/index.html?" Is it possible to do it only by editing web.xml file? ...

Can't access locally hosted project via the internet?

I'm currently developing a Java Servlet Project in Eclipse. The project is compiled via Tomcat 5.5 and hosted in localhost:8080(alternatively 127.0.0.1:8080 AND 192.168.1.10:8080 which also happens to be my local IP). The hosted project can be accessed on another computer via my Intranet(Local Network) at 192.168.1.10:8080. It should be...

onscreen keyboard

hi i want to make a onscreen keyboard in java but the problem is when the focus is lost how can we send the keystroke on another application through my java proogram ...

Recursive function to generate all combinations of capitals in a word

Hey there, Does anyone know the logic behind creating a recursive function to generate all combinations of capitals in a given word? I'm trying to do this in Java... For exmaple, give it the word "ben" and it outputs: Ben bEn beN BEn BeN bEN BEN But for any length word... any help appreciated! Thanks, Ben ...

To use or not to use Scala for new Java projects ?

Hi, I'm impressed with twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java ? EDIT: And, do you think google's Noop, Fan or Scala can take the leadership from Java in the near future, which one have chance in your opinion ? ...

how to set java library path for processing

Hi, I'm using pde to run a processing app , and I got the following error : "Verify that the java.library.path property is correctly set" . could anyone of you tells me how to solve this problem ? thanks in advance . ...

translating outer join SQL query into EJB entity beans

I'm new to EJB and trying to get my head around translating SQL concepts to EJB entity beans. Suppose I have two tables: PEOPLE (id, name), CONTACT(pid, phone_number). If I want to get a list of all people whether or not they have phone #s, in my EJB session bean I simply issue a SQL query via JDBC such as: SELECT PEOPLE.name, CONT...

How to properly display a price up to two decimals (cents) including trailing zeros in Java?

There is a good question on rounding decimals in Java here. But I was wondering how can I include the trailing zeros to display prices in my program like: $1.50, $1.00 The simple solution of String.format("%.2g%n", 0.912385); works just fine, but omits the trailing zero if it is at the last decimal place. The issue comes up in my pro...

How can I assign final variables of the base class within a derived class' constructor in Java?

I have a base Color class that looks something like this. The class is designed to be immutable, so as a result has final modifiers and no setters: public class Color { public static Color BLACK = new Color(0, 0, 0); public static Color RED = new Color(255, 0, 0); //... public static Color WHITE = new Color(255, 255, 255...

How to invoke a browser via Java coding?

I want to invoke a browser (e.g. Internet Explorer/Firefox/Google Chrome/Opera) via a Java interface. Also I need to pass some web links to this Java process. How to achieve this? ...

concept of class and object

which come first class or object in object oriented languages ? ...

modularization of methods - stack operation during method call - java

Hi , Generally we need to modularize our design.ie., we have to breakup our application logic into set of small functions.And then integrate these functions to achieve our ultimate functionality.But from the language(java) perspective ,invoking a method involves more stack operations(push and pop the method address from stack).How to com...

How to iterate through a Collection<Set<IConnection>>

I have something like this: something need here = scope.getConnections(); //getConnections() returns Collection<Set<IConnection>> I need to iterate through all connections (the stuff that the getConnections() returns) How to do that ? ...

SSL and NIO Non-blocking Sockets

How do you recommend making a highly scalable SSL client? Currently, I'm using plain Sockets to connect to the Apple APNS server which requires a non-HTTP SSL sockets. I considered using the NIO library, but it is lacking a SSLSocketChannel, and I couldn't find a good library or a smooth tutorial on how to roll out your own. ...

java RMI via SSH v2 protocol

Hi All , How to implement java RMI over SSH v2 protocol.Is this possible?.If its not possible then can i achieve this using raw socket communication?.Simply i want to transmit my data via RMI but it should be encrypted as SSH v2 packets . ...

how to use the toString() method for multiple enum members in same class in Java

I am trying to add more user friendly descriptions for multiple enum members in the same class. Right now I just have each enum returned in lowercase: public enum Part { ROTOR, DOUBLE_SWITCH, 100_BULB, 75_BULB, SMALL_GAUGE, LARGE_GAUGE, DRIVER; private final String description; Part() { description = toString()....