java

Memory allocation : How much space does a reference occupy in Java?

In Java we have written a code: A a1; a1 = new A(); How many bytes of memory is reserved when compiler compiles the code: A a1; ...

Java - HashMap vs Map objects

What is the difference between the following maps I create (in another question, people answered using them seemingly interchangeably and I'm wondering if/how they are different): HashMap<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>(); ...

Simple JMS Clients on OS X

I haven't touched any J2EE stuff in years and I need to whip up a quick JMS client for a demo. I'm using Eclipse, on OS X and I can't even get started because I can't seem to figure out how to get the required libraries. This is supposed to be a simple stand alone application (not running in a container) that pulls messages from a top...

Instance Method call in Java

In Java, for each object, a new copy of instance variables is created which can be accessed using the object reference. But in case of an instance method, only one copy of it(instance method) exists. How is this method accessed by various object references? ...

How to make a JSR-168 portlet with a chart?

I'm trying to make a JSR-168 portlet with a chart. Studying about it i can run some portlets in NetBeans with portlet-container but i have to make some charts to run too. Can some one help with a LINK or an Example? I found that to help me: -> dojocampus.org -> dojotoolkit.org -> extjs.com I make a chart, but when i put on portlet-con...

Boolean expressions optimizations in Java

Consider the following method in Java: public static boolean expensiveComputation() { for (int i = 0; i < Integer.MAX_VALUE; ++i); return false; } And the following main method: public static void main(String[] args) { boolean b = false; if (expensiveComputation() && b) { } } Logical conjunction (same as &&) is a commutative o...

what does MIME type for computer system means?

My client gave me the following requirement. I am not able to understand what he means He says: I'm looking for a Java application that sets a mime-type for the user's computer system. The application would be a very simple app (probably a single .class file?), which when run, sets this mime-type for the user's compute...

Handling unparseable strings in a JSP date formatter

I'm writing a JSP that sometimes needs to format a Java Date that comes out of the request. I'm doing it like this: <fmt:formatDate value="${attribute.value}" pattern="yyyy-MM-dd HH:mm:ss"/> and it works beautifully on Java Dates. However, there are times that the request attribute field with the exact same name (attribute.value) is ...

How can I get Maven to stop attempting to check for updates for artifacts from a certain group from maven-central-repo?

I'm working on a fairly big Maven project. We have probably around 70 or so individual artifacts, which are roughly split into two libraries of shared code and maybe ten applications which use them. All of these items live in the namespace com.mycompany.*. Most of the time we're running against snapshot builds. So to do a full build ...

Jar placement for Web Apps using WebLogic

This seems like an elementary question, but I want to make sure that we're doing things right. We're making webapps using Spring MVC and serving them using WebLogic. Where should jars be placed in this setup? We have talked about placing business logic into jars that would live in the server classpath and app-specific jars would be pac...

mobile to mobile TCP socket connection

Reading among the list of possibilities of the Java ME platform, its possible for a J2ME app running on a mobile to initiate a TCP Socket or HTTP connection with a server. On similar lines, Is it possible to form a TCP socket connection between two mobile phones? ...

Java - Reference implementations vs 3d party vendor provided ones

Dealing with Java - which the option you prefer in the most cases - reference impl. of some technology or another one, provided by any other vendor? Some examples - there is Glassfish server, which is basically official reference implementation of the JEE. However, i really seldom see people use that. Jboss, some free Apache projects re...

Finding all disconnected subgraphs in a graph

I have a graph which contains an unknown number of disconnected subgraphs. What's a good algorithm (or Java library) to find them all? ...

What should I set JAVA_HOME to on OSX

Many java applications that use shell scripts to configure their environment use the JAVA_HOME environment variable to start the correct version of java, locate JRE jars, etc. On OSX 10.6, the following paths seem to be valid for this variable /Library/Java/Home /System/Library/Frameworks/JavaVM.framework/Home /System/Library/Framework...

lucene set boost on fields at search time

Is it possible to adjust the boost of a field with the Query object before running the search? I know the proper way to do it is to change the fields boost during indexing, but it takes about 4 days to make an index and was just wondering if there's a quick hack i can do for now. also i have tried hardcoding in the boost to the search q...

Authentication type in DD paragraph confusion

Hi, Could anyone please tell me why the following paragraph is incorrect: If your deployment descriptor correctly declares an authentication type of BASIC, the container automatically requests a user name and password whenever a user starts a new session. ...

Convert JPanel to image

Is there a way to convert a JPanel (that has not yet been displayed) to a BufferedImage? thanks, Jeff ...

.NET equivalent of java.awt.color.ColorSpace

I'm trying to port a library from Java to .NET that makes heavy use of the java.awt.color namespace. What is the .NET equivalent to this? ...

Reading Input and Error Streams Concurrently using BufferedReaders Hangs

First off let me apologize to the SO community for coming to you with something that ought to be so trivial. But I've been at this all day and I'm at the end of my rope. There is a section of my program that needs pull text from an input stream and an error stream from a process that is launched using Runtime.getrunTime().exec() and pa...

Lucene search results sort by custom order list (unique to each user)

I have authenticated users in my application who have access to a shared database of up to 500,000 items. Each of the users has their own public facing web site and needs the ability to prioritize the items on display (think upvote) on their own site. out of the 500,000 items they may only have up to 200 prioritized items, the order of ...