java

what is the use of having public methods when the class is having a default access modifier?

as for my observation when the class itself is having default access modifier, what is the use of having public methods in it. the java compiler could have stopped using public methods in default class. is there any reason for that? ...

How to scale JPEG images with a non-standard sampling factor in Java?

I am using Java AWT for scaling a JPEG image, to create thumbnails. The code works fine when the image has a normal sampling factor ( 2x2,1x1,1x1 ) However, an image which has this sampling factor ( 1x1, 1x1, 1x1 ) creates problem when scaled. The colors get corrupted though the features are recognizable. The original and the thumbnail...

MPI , Sungrid vs JPPF ?

Greetings , I have a little experience with SungridEngine and MPI (using OpenMPI). Whats the different between these frameworks/API and JPPF ? ...

Hibernate Validation and Spring 3.x

I am trying to use validation with Spring 3.x. I have annotated a method field with @Valid, added <mvc:annotation-driven/> to my common.xml, and added Hibernate-Validator.jar in the lib/ dir, but I keep getting this message: "Hibernate validator not found: ignoring". Am I missing something? [Version:15] Hibernate Annotations 3.4.0.G...

java.lang.NoClassDefFoundError: com/google/common/base/internal/Finalizer$ShutDown (wrong name: com/google/common/base/internal/Finalizer)

Our application uses the MapMaker class from Google collections, and we're getting the exception below, but only on OS X 10.4 using webstart. It works fine when launched from an app bundle, and on OS X 10.5 and Windows. This has started happening since our upgrade from RC2 to RC5 (we skipped all the intervening versions). We've since ...

How to process Sound with Java?

Hey, i have to implement the LPC (linear predictive coding) Algorithm with Java and quiet frankly don't have a clue where to start. Could someone please point me into a right direction.. I can't. of course, use already implemented algorithms from the java sound api (if its provides a solution). thanks for you help fabian ...

Jaxen /text() not working

I have the html: <p> <a href="#">click here</a> Welcome </p> And I just want to retrieve the "Welcome" part using Xpath combined with the Jaxen lib the Xpath I am using is; //p/text() Now when I remove the /text() it retrieves; click here Welcome With the /text() added it retrieve null Is there any other way to retrieve everythi...

Why form submission doesn't work?

I have next form: <h:form> <h:selectManyListbox value="#{reports.selectedCategories}" converter="#{categoryConverter}"> <f:selectItems value="#{reports.categories}"/> </h:selectManyListbox> <h:commandButton value="Submit" action="#{reports.action}" /> </h:form> I use custom converter to t...

in velocity can you iterate through a java hashmap's entry set() ?

Can you do something like this in a velocity template? #set ($map = $myobject.getMap() ) #foreach ($mapEntry in $map.entrySet()) <name>$mapEntry.key()</name> <value>$mapEntry.value()</value> #end ...

why cant we overload a method on throws exception basis also?

why cant we overload a method with same return type, name, arguments but with some throws exception? as shown public String getAppletInfo(){ } public String getAppletInfo() throws Exception{ } ...

Launching Java Subprocess using parent process Classpath

I want to launch a java subprocess, with the same java classpath and dynamically loaded classes as the current java process. The following is not enough, because it doesn't include any dynamically loaded classes: String classpath = System.getProperty("java.class.path"); Currently I'm searching for each needed class with the code below...

Recommended number of lines per Java class file

When getting metrics from a project, if you want to evaluate if a class is way too big, apart from other things, you can look at the number of lines. For Java in particular, what would you say a recommended number would be? I'm looking for a number to be used as part of my continuous integration server checks. Java code conventions (f...

Weird Java generic

What does this mean? HashBiMap<Character, Integer> charOcc = HashBiMap.<Character, Integer> create(); ...

How to securely store a PrivateKey in code

I'm working on a software project where the application will end up being run in an untrusted environment. I have a need to perform some ancillary cryptographic signing (meaning this is not the primary means of securing data), but do not wish to leave the key in plain view as such: private static final String privateKey = "00AABBCC.......

JSF Managed Bean auto-create?

Is it possible to have a JSF managed bean be automatically created? For example I have several session scoped beans. Sometimes it becomes necessary to access these instances in code (rather than just in JSF) this is done by: PageBean pageBean = (PageBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("pages...

Invoking statically imported method with explicit type parameters

This is the follow up of my question here: http://stackoverflow.com/questions/2050202/weird-java-generic. If I have a code like this: Casts.<X, T> cast(iterable[index]); Can I add a static import and do: <X, T> cast(iterable[index]); Eclipse doesn't allow this. But after seeing so many bugs with static import in Eclipse, I'm not t...

python to Java checksum calculation

I received this python script that generates a file checksum: import sys,os if __name__=="__main__": #filename=os.path.abspath(sys.argv[1]) #filename=r"H:\Javier Ortiz\559-7 From Pump.bin" cksum=0 offset=0 pfi=open(filename,'rb') while 1: icks=0 chunk=pfi.read(256) if not chunk: break #if EOF exit loop for iter in chunk: ...

Running multiple versions of a servlet web application parallel

I want to run multiple versions (like myapp2.1, myapp2.2 ...) of several Java Servlet based web applications parallel. One possibility could be to deploy each version to a separate servlet context (which should have its own class loader?!). But I think it will be hard to manage and won't be flexible, since an application is a quite larg...

PHP __call equivalent for java

Is there a Java equivalent for the __call of PHP? It would make sense to me if that's not the case, because it would probably result in compiler errors. From the PHP manual on magic methods: __call() is triggered when invoking inaccessible methods in an object context. ...

What collection to use instead of 2D array in Java?

I want to use a collection in place of 2D array so that I don't need to give its size at the time of declaration and I can add as many elements as I want dynamically. ...