java

Is Sun Java Certification worth the expense? Will it help me start a programming career?

The certification's cost between $300-400 per exam which is pretty expensive. I'm still a java newb but eventually I would like to get a job in the field of computer programming and I'm wondering if the Sun Java certifications would help. Especially considering that I do not have the time or money to get a degree. ...

java class recompiling

I have a program where some java classes are available. It is possible to decompile them. Is it possible to modify the source code of a class and recompile it, without having all the other .class ? For example, suppose I have a dog.class file, that implement a subclass of animal, which is defined in animal.class. - Can I recompile dog...

Differences between Java interfaces and Objective-C protocols?

I know Java, and now I'm learning Objective-C. What exactly are the differences between Java interfaces and Objective-C protocols? ...

Why do I get an error in my JSP local functions '<%!'?

We have a couple of utility functions declared on class level in jsp. Using <%!. I get the following error in the line containing only <%!: Invalid character constant Code: <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@page import="java.sql.*"%> <%@page import="java.util.V...

Simple Thread Management - Java - Android

Hi, I have an application which spawns a new thread when a user asks for an image to be filtered. This is the only type of task that I have and all are of equal importance. If I ask for too many concurrent threads (Max I ever want is 9) the thread manager throws a RejectedExecutionException. At the minute what I do is; // Manage Co...

Swing: How to make non-rectangular windows with soft borders?

Hello! How could I make non-rectangular windows with soft borders in Java? Soft borders (also known as soft clipping) are borders without aliasing artifacts. I searched the web a lot and found several posts about translucent and/or non-rectangular windows. The topic "soft border" is confusing. It seems that the information I found dea...

jars for mass email sending

in my webapplications whihc runs on tomcat on widows i want to send email to many different people for example whenever a new tutials is uploaded on my site an email shold go to all the registed user on my site. simlarly whenever some other event occors i need to send the email to some selected users whose emailid are picked up from data...

Does anyone know of a java2d text library?

This is what I need in my game regarding text: Word Wrap Support given a bounding box Vertical and Horizontal alignment given a bounding box Now, I've been reading about how to use TextLayout, and it seems possible to write all this myself but I'd prefer to think at a higher level. I just want a Label class with a signature like this:...

resize image with keeping aspect ratio in java

hello all im trying to resize bufferdImage in memory in java but to keep the aspect ratio of the image im have something like this but this is not good int w = picture.getWidth(); int h = picture.getWidth(); int neww=w; int newh=h; int wfactor = w; in...

I can't delete a file in java

I'm trying to delete a file, after writing something in it, with FileOutputStream. This is the code I use for writing: private void writeContent(File file, String fileContent) { FileOutputStream to; try { to = new FileOutputStream(file); to.write(fileContent.getBytes()); to.flush(); to.close(); ...

Flickr API + JAVA - flickrj

I want to download a set of photos of a particular user in Flickr using the Flickr Java API (flickrj) Does anybody knows how to do it? I've stated with this code: Transport t = new REST(); Flickr f = new Flickr(key, secret, t); User u = f.getPeopleInterface().findByUsername("username"); What should I do next? ...

Can i deny access to a jvm class by configuring java.policy file ?

I wanted to create add to my jdk6\jre\lib\security\java.policy file an interdiction to create some classes that are blacklisted by appengine. For example I want my local jvm to throw an exception when the application tries to instantiate javax.naming.NamingException. It is possible? I will try to explain my specific problem here. Googl...

Is there any speed/efficiency benefit to setting a class' instance variables in a constructor rather than in their declaration if they'll have a "default" value?

For instance: public class Foo { private int bar = 42; Foo() {} } vs public class Foo { private int bar; Foo() { bar = 42; } } Is there any cost/benefit between the two methods? The only way I could see it making a difference is in a scenario like this (where you're setting a value twice for the second...

how do I change persistence.xml at run time

Hello guys, I am new to openJPA. I have a scenario where, depending upon the server where my application is running, I need to change the settings to persistance.xml. For eg. if its running on Server A, then it should use different database(different url), different password etc. and if the application is running on Server B then it sh...

Best practice for parameter naming in Java constructors and simple setters

Is there a standard acceptable convention for parameters in Java to straightforward constructors and setters? (I've seen the answer for C++, but practices are often different between the two communities) Suppose that I have a class C with a foo field. I have commonly seen the following three options: 1) Use the actual field name with ...

How to tell which SHIFT key was pressed?

In my game, I want to be able to use the right and left shift keys for different functions. In Java (or another language), is there any way to distinguish between those two? The KeyEvent class has only VK_SHIFT, which corresponds to both left and right shift keys. Same with Control, Alt, Enter, etc. My primary concern is someone may be...

different ways to define a method in an interface

Is there any difference between: interface A{ public a(); } and interface A{ abstract a(); } and interface A{ a(); } ...

Why is there no GIL in the Java Virtual Machine? Why does Python need one so bad?

I'm hoping someone can provide some insight as to what's fundamentally different about the Java Virtual Machine that allows it to implement threads nicely without the need for a Global Interpreter Lock (GIL), while Python necessitates such an evil. ...

Design patterns for managing results of large operations

We frequently have objects that perform multi-part operations/tasks. An example would be refreshing internal state of a list of objects based on a query of the file system and reading data from the found files. These things are also often long running, and tend to be performed in background threads (we do a lot of Swing work, but I thi...

Java 256bit AES Encryption

I need to implement 256 bit AES encryption, but all the examples I have found online use a "KeyGenerator" to generate a 256 bit key, but I would like to use my own passkey. How can I create my own key? I have tried padding it out to 256 bits, but then I get an error saying that the key is too long. I do have the unlimited jurisdiction pa...