java

Thread in App Server

I have a Java program/thread that I want to deploy into an App Server (glassfish). The thread should run as a "service" that starts when the App server starts and stops when the App Server closes. How would I go about doing this? Its not really a Session Bean or MDB.. Its just a thread. ...

Where can I find the source code for J2ME?

I am currently working in J2ME. I would like to link the source code of J2ME with my Eclipse installation so that I can go through the contents of it and also it will help me in debugging. I am quite used to this when the source code of J2SE was (is) available in jar format and you just need to link it to Eclipse. Could you please prov...

Extra button on title bar for Swing GTK L&F

Hi, Anyone know of anyway to add an extra button next to the general maximize, minimize, restore, and close button on the title bar in Swing GTK L&F? Thanks much. ...

How to create a JAR that depends on another JAR?

I'm trying to do a modular application, and I'm having a problem because I have two modules, where one of them depends on the other. For example: module 1 has a class that imports classes from module 2. I've put the following line in my Manifest.txt of module 1: Class-Path: modulo_2.jar ... but I'm getting a error when I create the...

Which data structure uses more memory?

Which type of data structure uses more memory? Hashtable Hashmap ArrayList Could you please give me a brief explanation which one is less prone to memory leakage? ...

Change a Specific Color in an ImageIcon

I am working with 24x24 pixel icons. And I would like to be able to change a specific color within this icon to a different color. For example turn the white areas to red. ...

Effective java book for c# programmer

I heard a lot about effective java book, as a c# developer is this book useful for me? Is it going to add a value to my c# knowledge, is it going to get me some confusion (no java experience at all)? Thank you in advance. ...

How do I keep Netbeans from printing line like this // <editor-fold defaultstate="collapsed" desc=" UML Marker "> when printing code?

I am trying to keep Netbeans from printing statement like this // <editor-fold defaultstate="collapsed" desc=" UML Marker "> // #[regen=yes,id=DCE.B7E25FE1-C10B-ED91-77... // </editor-fold> without deleting them from the code. ...

Understanding C++ compilers from a Java / C# perspective

I'm a moderately experienced Java / C# programmer, and I've recently started learning C++. The problem is, I'm having trouble understanding how to structure the various header and code files. This seems mostly due to my lack of understanding as to how the compiler links everything together. I've tried reading some textbooks, but my preco...

What strategy do you use for package naming in Java projects and why?

I thought about this awhile ago and it recently resurfaced as my shop is doing its first real Java web app. As an intro, I see two main package naming strategies. (To be clear, I'm not referring to the whole 'domain.company.project' part of this, I'm talking about the package convention beneath that.) Anyway, the package naming conven...

Dynamic dispatch and binding

Are dynamic dispatch and dynamic binding the same thing? Thanks Maciej ...

How do I test a message queue client?

I am working on a java message queue client (beanstalk) and right now my tests look like this: //make sure our getJob can handle utf8 characters @Test public void testUTF8() { bean = new Beanstalk(); Job job = new Job(); bean.putJob("€"); job = bean.getJob(); assertEquals("€", job.msg); bean.close(); } ...

Java sound: what's the persistence of set controls ?

Hiya - still @ the design stages of an app, and was wondering about the following with regards to Lines of type 'Port': do the values entered last once the port is closed (it seems that port controls are only accessible if I open the port before asking for the port's controls)? do the values entered impact only my applications access t...

protected/private - why bother?

DUPE: http://stackoverflow.com/questions/99688/private-vs-public-members-in-practice-how-important-is-encapsulation In the course of writing a program in Java, I have abstracted out some libraries that I can see a possible use for in future projects. Why should I bother with setting restricted access (private/protected) on any of the...

How to approximate a vector contour from an elevation raster?

I have an elevation map stored as a raster. I'd like to fit a smooth "vector" curve to the contours of constant elevation. In my application, the data are actually geographic elevations, but the problem could be generalized to any function of two variables. I can produce another raster with anti-aliased contour lines, and use that as in...

how to skip well-formedness check XML

Hi, I am using Xpath (and java) to extract information from some websites. However my problem is that since some of these websites are not well-formed, I cannot process them. Is there any way to avoid well-formedness check or alternatively specify tags that should'nt be checked for well-formedness? Thanks Rp ...

Total number of loaded classes in Glassfish

I have enterprise app with EJB. The total size of the app is 34 meg. When i deploy my app everything is fine but when I redeploy it the number of total loaded classes increases. I'm using visualVM to see this info. So is it how it should be or it's a memory leak. How to solve this problem? Thanks ...

Analyzing XML schemas using org.eclipse.xsd and Maven2

I'm trying to implement the sample code to this article from 2002 (I know..), but cannot get the schema to load. import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.xsd.uti...

Why spawning threads in J2EE container is discouraged?

One of the first things I've learned about J2EE development is that I shouldn't spawn my own threads inside a J2EE container. But when I come to think about it, I don't the reason. Can you provide a clear explanation why it is discouraged? I am sure most enterprise applications need some kind of asynchronous jobs like mail daemons, idl...

Is it OK to use == on enums in Java?

Is it OK to use == on enums in Java, or do I need to use .equals()? In my testing, == always works, but I'm not sure if I'm guaranteed of that. In particular, there is no .clone() method on an enum, so I don't know if it is possible to get an enum for which .equals() would return a different value than ==. For example, is this OK: pu...