java

Explanation of serialization in Java

Can anyone explain working of serialization in java ...

How authenticate Google wave gadget viewer on Appengine?

Imagine I want to create game "Rock-paper-scissors" for Google Waves. I am thinking to implement it as a Wave Gadget. The idea is simple: all participants send their decisions to my cloud app (it is an Appengine Java Application), my server part collects this data and does not share to anybody until all participants complete their selec...

Does javadoc have an equivalent to <![CDATA[ ... ]]> ?

Unfortunately, there is no CDATA in HTML. This is a pity, because it would be perfect for adding javadoc comments that include XML, so you don't have to escape the < and >, for example: /**<![CDATA[ This parses <complexType name=""> ]]>*/ However, it would be possible for javadoc to recognize the CDATA section, and convert it to HTML...

JTabbedPane: icon on left side of tabs

hello i am using the nimbus look-and-feel and have a tabbedpane with an icon and text. now the icon appears on the right side of the text, while i would like to have it on the left side. also i would like to add some spacing between the icon and the text. thanks! ...

Filtering Maven files into WEB-INF

I am trying to add some filtering to the application context file, which resides in the WEB-INF directory. I have the file which is to be filtered (xmlgateway-context.xml) in the folder /src/main/resources. I have the properties files (config-e05.properties) in the folder src/main/filters And I have the POM set up as follows: <!-...

Using final object in anonymous inner class results in null

I have a method that contains the following code: public void myMethod(){ final MyDto expectedtDto = new MyDto(); MyRepository reposWithMock = new MyRepository(){ protected MyDao createDao(){ return new MyDao() { public MyDto someMethod(){ return expectedtDto; ...

Is it possible to monitor jboss if it happens to run out of memory?

Sometimes when I redeploy war too many times, jboss gives java.lang.OutOfMemoryError: PermGen space error, is it possible to monitor jboss with other Java program that is not run inside jboss, to make sure it has not run ot of memory and if it is, then automatically restart jboss? ...

persisting persistence; or moving legacy webapp to non-relational store

Suppose you have a huge app with a data access layer bound to SQL You want to provide other non-sql DAL, for instance a GoogleAppEngine instance or XML-based backup. How would you approach this migration to a different storage paradigm but with limited flexibility, since it is legacy. I might be missing info here, but One solution I ha...

J2SE Question, constructor auto run?

I have wrote C# few years and start to learn java, today i saw a sample is strange ,which is cannot happen in C#. from http://www.java2s.com/Tutorial/Java/0261%5F%5F2D-Graphics/Drawrectangles.htm public class MainClass extends JFrame { public static void main(String[] a){ MainClass f = new MainClass(); f.setSize(300,300); ...

how can i retrieve the msg from HttpServletResponse.sendError

i have two tomcat servers that communicate between them. upon an error at one of the servers i would like to send an error response to the other server. i am sending the error using: resp.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); i am catching the response with org.apache.commons.httpclient.httpMethod. my questio...

Illegalkeysize exception

I am using the Bouncy Castle Java cryptographic algorithm implementation. I am getting an IllegalKeySizeException. To overcome this I have even changed my java security jars (local_policy.jar and US_Export_policy.jar), but I am still getting the same problem. Can anyone suggest a solution for this (I am using centos operating system)? ...

Grails Integration with another Spring app - dataSource being overloaded.

Hi, I'm currently in the process of building a CRUD tool for an existing Spring-based application. The application is being included in the Grails app as a JAR library which seems to work fine. To make use of the library's own spring context, I used to load it through: def ctx = new ClassPathXmlApplicationContext( 'classpath:/applicat...

creating a queue in JBoss MQ

I'm trying to call send a message to a JBoss MQ queue but it seems the queue is not bounded. I use the following code to send the message : Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");...

With Java reflection how to instantiate a new object, then call a method on it?

Hi, I'm pretty new to Java, and I'm facing a reflection issue. Let's say i have to dynamically call the method fooMethod on an instance of the class Foobar I got so far an instance of Foobar with: Object instance = Class.forName("Foobar").newInstance(); Let's say I know there's a method fooMethod on this object (I can even check t...

Best API for modeling networked devices with arbitrary attributes to learn from?

I need to design a new API which models networked devices which have a large amount of attributes which vary quite a lot based on the device's type. The attribute set is not totally arbitrary though, it is a big set of known attributes. That said, with new devices come new attributes so the situation is never totally fixed. The network...

Getting exception of org.dom4j.DocumentException : feature read only while deploying war file in tomcat of linux

Hello All... I have working copy of war file which is working fine in windows.. Now when i am deploying that war file into linux + tomcat, it's giving me following stacktrace : 2009-11-23 17:06:08,675 INFO (org.springframework.jdbc.datasource.DriverManagerDataSource:153) - Loaded JDBC driver: com.mysql.jdbc.Driver 2009-11-23 17:06:08...

How to set the Return-Path to an email address other than Sender address using JavaMail?

How to set the Return-Path to an email address other than Sender address using JavaMail? ...

Java TreeMap (comparator) and get method ignoring the comparator

public final Comparator<String> ID_IGN_CASE_COMP = new Comparator<String>() { public int compare(String s1, String s2) { return s1.compareToIgnoreCase(s2); } }; private Map< String, Animal > _animals = new TreeMap< String, Animal >(ID_IGN_CASE_COMP); My problem is, how to use method get(id) ignoring th...

How to create Java applets?

I am just stepping into Java and need help with some basic things. I want to create an applet. Where should I start? ...

Java: Alternative to iterator.hasNext() if using for-each to loop over a collection

I'm trying to replace an iterator-based loop over a Java list with a for-each statement, but the code uses at some point iterator.hasNext() to check if it reached the last element in the list. Is there something similar for the for-each alternative? for (Object current : objectList) { if (last-element) do-something-special ...