java

Long list of if statements in Java

Hi, Sorry I can't find a question answering this, I'm almost certain someone else has raised it before. My problem is that I'm writing some system libraries to run embedded devices. I have commands which can be sent to these devices over radio broadcasts. This can only be done by text. inside the system libraries I have a thread whi...

JDBC unwanted statement close

Hello I have a Java JDBC application that uses multiple threads to retrieve information from an Oracle data base. Each thread si supposed to periodically execute a statement that executes a select on a specific table (the table is different for each row). The threads are instances of a class that extends the Thread class. This class ha...

JAVA 6 ServiceLoader

I recently posted a question regarding a way to define the implementation of an abstract service on the client side. dfa mentioned java.util.ServiceLoader as a solution for my problem. I ended up going in a similar way, though not using ServiceLoader directly, mainly because i was using JDK 5. But another SOer jut went into panic when...

How should I redirect the second page in Spring framework

My application has 3 JSP pages: one is login.jsp, and the others are loginSuccess.jsp and loginFail.jsp. If the username and the password in the login form are correct then it goes to the loginSuccess page but when the username and password are not correct, it doesn't go to the loginFail page. What do I need to do to get it to work? ...

is my Enumeration correct ?

All over our project, we have this kind of enums. They works just fine, but we are not sure about them. Specially with the getDocumentType(String) method. Is there a way to avoid the iteration over all the Enums field ? public enum DocumentType { UNKNOWN("Unknown"), ANY("Any"), ASSET(Asset.class.getSimpleName()), ME...

Why is System.console() set if executed with java and unset if executed via ant?

I wrote a little commandline-application in Java and wanted to use the new class java.io.Console for this. I use System.console() to get an instance of this class. This call returns a working console, if I call my application via 'java -jar MyApp.jar' but is unset if I execute the application via the java-task of ant. fork is true and sp...

Caching using Axis 1.4 + web service response caching at client side

I want to cache web services response XML at client side. How can i cache response XML at client side, so we don't have to wait for Server side response ? Is there any mechanism available in Axis 1.4 that helps to caching server side response XML at client side ? Scenario : I am consuming 1 search detail service method, which hits the ...

SWT Multiple Monitor Support on Solaris?

I am writing an application in Java using SWT. On our Solaris machines, we have multiple monitor setups, but they are treated in isolation by the operating system. This means I can't open the application and drag it to another monitor. The right-click context menu doesn't even allow me to change the monitor the application is displayed o...

Java library for parsing command-line parameters?

I write a little command-line-application in Java. This application should work with a mix of parameters and commands, a little bit similar to the 'svn'-command. Examples: app url command1 app url command2 --parameter2 -x app url command1 --param-with-argument argument app --parameter url command1 app --no-url command2 app --help Exi...

JAAS tomcat login module possible method to pass ip address

I've been looking into a way of passing the client ip as well as the userid and password from a JAAS login page to the JAAS login module implementation in my web code. JAAS only allows the user id and password to be passed to the login module. My idea is to have a java script code to append the ip address to the user id and then call t...

Can a Java applet retain a socket connection when going to a new web page?

I have an applet that I want to maintain a socket connection between multiple web pages. Currently, when a transition is made to a different page, the socket connection is closed. Is there anyway of maintaining that connection between web pages? Or, do you have to reconnect the socket after each web page transition? ...

JBoss/EJB - location of custom configuration file

I'm implementing an EJB-based system in JBoss. One of my message driven beans will be responsible for sending emails. I want the email template to be stored externally (probably as XML) so that it can easily be changed without having to change the code/redeploy the bean, etc. Where should this file be placed and how do I reference it?...

log4j redirect stdout to DailyRollingFileAppender

I have a java app that uses log4j. Config: log4j.rootLogger=info, file log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File=${user.home}/logs/app.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d [%t] %c %p %m%n So all the log statements a...

Cant save Report in formats other than .html in jasperviewer

im using Netbeans 6.5 . n for reports im using jasper reports. When i go 2 save the file in jasper viewer, it does not save it in format other than .html. i.e. it does not save in .pdf or .xls format. instead it throws an exception... Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/lowagie/text/pdf/FontMapper...

unit testing a java constructor that exits the application

Duplicate: Java: How to test methods that call System.exit()? Hello, I am having a bit of a trouble designing a unit test for a method that exits the application by calling system.exit(). Actually this is the constructor of a class which tests some conditions and decides to exit the application. So it is this particular eventuallity th...

UnsupportedClassVersionError

I am trying to run some java code using putty. I have all the jar files I need in a folder and when in the folder with the 'classname.class' folder I try to run the file but I get the following error. Exception in thread "main" java.lang.UnsupportedClassVersionError: dueDate (Unsupported major.minor version 49.0) at java.la...

How do I adjust log4j levels at runtime?

I have a simple web app running on Tomcat 5.5 with log4j for logging. Occasionally I need to push the logging down to DEBUG but most of the time I'm happy with INFO. I can change my config xml and restart the app but I would prefer to switch the log levels on the fly. Is there a standard technique for this? ...

Java Netbeans BeanCreationException

Hi Im trying to deploy netbeans java ee project ( maven + hibernate + JSF ) on glassfish Im getting error below. My database configuration is ok ( double checked from several apps ), and database itself is ok and online. SEVERE: WebModule[/web-0.1-SNAPSHOT]PWC1275: Exception sending context initialized event to listener instanc...

How to declare an array in Java?

How do I declare an array in Java? ...

Xerces JAR on GAE project's classpath leads to "SAXParserFactoryImpl not found"

I'm using the Eclipse plugin for Google App Engine and I'm having a strange issue with a Xerces dependency. On of my classes depends on the Apache Xerces JAR which I have added to the project's classpath. This however, triggers an error when starting the Jetty app server: WARNING: failed com.google.apphosting.utils.jetty.DevAppEngine...