java

Problem with scoped local variables and conditionals

Hello, I am trying to construct method which returns a boolean: public boolean isStringValid(String s){ boolean isValid; String temp = null; // only combinations of 'A','B','C' are allowed for (int i = 0; i < s.length(); i++) { temp = s.substring(i, i+1); if (temp.equals("A")|temp.equals("B")|temp.equals("C")){ isValid= t...

nested jobs in Quartz

I have nested task to schedule: (1). A daily master task downloading scheduling information, which is a List of job names with timestamps (2). schedule the job in the scheduling information I just downloaded according to its timestamp I am not sure how the nested jobs work in Quartz. It seems that I need a CronTrigger triggering a job,...

Is it possible to re-use @param descriptions in JavaDoc?

I have a convenience class for encoding URI's. In it I've created three methods which I use depending on how specific I need to be. I'm wondering if there is a smart way to re-use @param descriptions in this case using JavaDoc? (I haven't found any) public class URLCreator { public static String getURLString(String host, int port, S...

Which static analysis tool for Java is easiest to extend?

Which static analysis tools for Java has easiest extension mechanism. I checked PMD But the process of writing custom rules appears to be very involved. Specifically, I want to know whether there is any tools that offers AspectJ like syntax for picking out interesting areas of code? I am aware of AspectJ's declare warning but it appear...

What is the usage of array of zero length?

for example we can construct such a this array like==> new elementType[0]; I have read this such a construct but I didn't get the whole such the usage of these arrays!!! :( ...

Split java strings in Rhino

I'm trying to split a java string in a Rhino javascript program var s = new java.lang.String("1 2 3"); s.split(); which give me the error js: Can't find method java.lang.String.split(). The Rhino docs mentioned that all the javascript String.prototype methods (like match, split, etc.) are available on java string if they're not al...

My class is not a servlet error

I have the following servlet code public void doPost(HttpServletRequest request, HttpServletResponse response){ Backup bup = new Backup(); bup.doBackup(); response.setContentType("text/html"); PrintWriter out; try { out = response.getWriter(); out.println("You backed up your data - well hopefully"); out.flush(); out.close()...

Tuning Tomcat memory and cpu consumption

Hello all. I have a Java web application that works a lot with file conventions. I am using Tomcat 6 as my servlet container. When many requests are submitted, Tomcat becomes very memory hungry. I wonder how I can fine-tune tomcat to reduce the memory consumption. I am also considering changing my servlet container. What do you suggest? ...

How many people have been stung by Java substring memory issues?

I recently discovered that the java.lang.String.substring method does not return a new string, but a view of the original string that was substringed. This can have memory implications. For example, if you're reading an ascii file, and parsing tokens in the file using substring and storing the result of substring in memory somewhere --...

Difference between wait() and sleep()

What is the difference between a wait() and sleep() in Threads? Is my understanding that a wait()-ing Thread is still in running mode and uses CPU cycles but a sleep()-ing does not consume any CPU cycles correct? Why do we have both wait() and sleep(): how does their implementation vary at a lower level? ...

Saving to a subversion repository from Java

I want to save to a subversion repository. I am using the command - svn commit -m \"\" ./cms_test/www My class is: public int doBackup(){ int exitVal=-99; try { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("svn commit -m \"\" ./cms_test/www"); exitVal = proc.exitValue(); System.ou...

calendar methods

apart from the inbuilt functions, can we use any simple formulas to calculate the start day of the month given month and year as inputs?? ...

First Loadtest fails after restart of weblogic server

We have encountered a peculiar problem. If we deploy our application and then restart the weblogic portal server; and we do a load test, the load test fails with very high response time and low throughput. If we the load test a second time, it runs just fine. If we just deploy our application, but don't restart the weblogic portal se...

Sending a HTTP POST request

To implement single sign off, i would like the user to get logged out of application B additionally when ever the user clicks logout on application A. Is it possible to implement this using some form of a POST request to application B? i.e. when the user clicks on logout: Generate existing POST request to logout of application A Genera...

JiBX "bind on load" and JUnit

Has anyone been successful in using JiBX "bind on load" mechanism while running a JUnit test case? What were the steps taken? How did you managed to use IDE test running integration with this solution? ...

Kerberos Authentication in Java - does "login" action in java equals to "kinit"?

Hi, I'm using GSSAPI in Java in order to login to an LDAP server using Kerberos authentication. I'm a newbie to Kerberos, so I'm sorry if this is an obvious question, but I couldn't find anything clear enough on the internet. I perform the following steps: Define Login configuration by setting the system property "java.security.auth....

Inheritance - Arrays of parent class and arrays of child class - casting

I'm having trouble with inheritance. I can do what I need with single instances of the parent class and child class - as expected the methods of the parent class work fine with instances of the child class. But, I cannot see how to extend a class that uses an array of the parent class, in a way that allow me to store an array of the ...

Swing versus SWT

What should I be looking at when choosing between SWT and Swing? I've had a little experience with both, but I'm interested in: layouts/layout managers; data binding; pre-built controls; ease of development. I will assume that they are both satisfactory in terms of GUI performance and of platform availability. ...

loop through JPanel

Hi there, In order to initialise all JTextfFields on a JPanlel when users click a "clear button" I need to loop through the JPanel (instead of setting all individual field to ""). Can someone please show me how to use a For Each loop in order to iterate thru the JPanel in search of JTextFields. Very much appreciated Dallag. ...

How do I start with EJB3 and JBoss?

I'd like to get into ejb3 to gain some practice in writing for it. I searched for tutorials and how-to's but could find some scarce unhelpful information. I'm looking for a tutorial or walkthrough that will guide me from the very basics (Which software do I need to install?) to write a "Hello World" for EJB3 with JBoss. In short - Wher...