java

How to have a specific component resize based on available, visible space?

Hi all, In my application, I have a layout similar to what is shown below: @@@@@@@ XXXXXXX*** XXXXXXX*** XXXXXXX*** %%%%%%% In this layout, X is a JTable. The other components can remain the same size. Is there a layout or strategy that will have the JTable (X) resize based on available screen size and have everything else stay on the...

understanding basic recursion

public static void main (String[] args) { System.out.println(factorial(5)); } public int factorial(int n) { if(n <= 1){ return 1; } else{ return n * factorial(n - 1); } } I wrote the above directly in here so may not compile but think it does. Can anyone breiefly explain how this works in the sence...

Automated conversion from XDoclet to annoations

Does anybody know of a way to convert xdoclet to annotations in an automated fashion? It seems to me that it should be possible to have equivalent annotations/annotation preprocessors for anything that xdoclet does but manually converting things is really tedious on large systems. ...

How can include multiple jars in the classpath using ant?

Hi, I have a bunch of .java files in a "src" folder that depend on three jars in a "lib" folder. I have the following build.xml file: <?xml version="1.0"?> <project name="MyProj" basedir="."> <property name="src" value="src"/> <property name="build" value="build"/> <property name="lib" value="lib"/> <path id="master-classpath"...

Java/JSP HttpServletResponse issue

Hi All, In my java class I am trying to do something like HttpServletResponse.setCharacterEncoding("UTF-8"); but the code fails to compile with the message: Depend attribute is not supported by modern compiler. If I remove this line, code compiles without any issues. Can anyone shed any light on this? Thanks ...

Java Mail: SSLHandshakeException when sending email on port 25 without SSL

Although I'm trying to send an email on port 25 without SSL, I'm getting an SSLHandshakeException. Below you can see debug messages printed by javax.mail.Session and the SSLHandshakeException. Can you help me understand what's going on? 22 Dec 2009 15:13:21,054 INFO root:197 - DEBUG: setDebug: JavaMail version 1.4ea 22 Dec 2009 15:13...

Why am I able to set -Xmx to a value greater than physical and virtual memory on the machine on both Windows and Solaris?

On a 64-bit Windows machine with 12GB of RAM and 33GB of Virtual Memory (per Task Manager), I'm able to run Java (1.6.0_03-b05) with an impossible -Xmx setting of 3.5TB but it fails with 35TB. What's the logic behind when it works and when it fails? The error at 35TB seems to imply that it's trying to reserve space at startup. Why wou...

String replace in Java

I currently have a string which contains the characters A, B and C for example the string looks like "A some other random stuff B C" the other random stuff doesn't contain A, B or C I want to replace the A, B & C with 'A', 'B' and 'C' respectively what's the best way to do that currently I'm doing: String.replace("A", "'A'").replace...

How to access dynamicmbeans from a jmx client

I am writing some test cases for the JMX interface in our product. I can access attributes from standard MBeans (following sun tutorial). However, I don't seem to be able to access dynamic MBeans. The attributes are fully (readable/writable) from JConsole. JMXConnector jmxc = getJMXConnector(); // Takes care of our connection MBeanS...

Are Axis2 generated stubs thread-safe?

Are client stubs generated from WSDL by Axis2 thread-safe? Of course, "thread-safe" isn't necessary a rigorously defined term, so I'm at least interested in the following: Are different instances of the same stub class accessible concurrently by different threads, with the same effective behavior as single-threaded execution? Is a sin...

Deploy J2ee Project in Weblogic

I have WebLogic installed in my computer. I already added it as a server in my Eclipse IDE. How do I configure my Web application to run or for it to be deployed on the WebLogic server. I found a sample project and found a weblogic.xml in it. Where do I start? Do I need to add something, etc. ...

Get Javascript tag content

Hi I want to save a website's source code into a file using java. From the source code i want to get only <script> </script> tag contents how can i do that? ...

How could I prove class loading take places only once in Java?

As the title implies, or is it a pseudo-proposition? thanks. ...

Java Reflect 2 objects

Hi i got the code below : ModuleA.Student student 1 = null; ModuleB.Student student 2 = null; student2 = retrieveStudentFacade().findStudentbyName("John"); student1 = StudentSessionEJBBean.convert(student2,ModuleA.Student.Class); The problem now student1.getId(); return null but supposed to return me a value. Below is the converter m...

synchronized method or use spring @transactional?

I have a method that will be used to send out email. i want to lock this method so only one thread can accses it per time and the rest pool up concurrently. should i synchronized the method or use spring @transactional PROPAGATION_REQUIRED ? in my service layer //each time use new thread to send out email public void sendThroughSMT...

How to reduce memory size of Apache CXF client stub objects?

My web service client application uses Apache CXF to generate client stubs for talking to several web services. The generated CXF web service stub objects have quite a large memory footprint (10 - 15 web service objects take more than 64 MB of memory). Is there any way to reduce the CXF object footprint? ...

Java: Why could base class method call a non-exist method?

class BaseClass { private void f() { System.out.println("Baseclass f()"); } public static void main(String[] args) { BaseClass dc = new DerivedClass(); dc.f(); } } class DerivedClass extends BaseClass { public void f() { System.out.println("DerivedClass f()"); } } In my opinion, the object ...

Problem on running GAE app on local machine

Everytime I try to run my app on my local machine, I get the following error messages (quite long, sorry): Initializing AppEngine server 2009-12-23 04:44:03.068::INFO: Logging to STDERR via org.mortbay.log.StdErrLog 2009-12-23 04:44:04.123::INFO: jetty-6.1.x 2009-12-23 04:44:10.632::WARN: failed projectrix java.lang.NoClassDefFoundEr...

Problem with JDO pagination

I have a unit test that populates the datastore with 26 entities. I have a DAO that tries to retrieve these entities and page through them but somehow I can't get it to work entirely. If I do query.setRange(0,10) it works but not for query.setRange(10,20). The query returns 0 results even if the unit test shows that I have 26 entities. ...

Anonymous Inner Classes Inside Methods

Please have a look at following code : import java.util.ArrayList; import java.util.List; class Main{ public static <T> List<T> modifiedList(final List<T> list){ return new ArrayList<T>(){ @Override public boolean add(T element){ super.add(element); return list.ad...