java

what is the difference between projects and libraries in eclipse's build path for any java project.

We can add project as well as a jar file in java projects build path in eclipse. so what is the use of it? ...

Extend from Generic Supertype?

In Java, am I able to extend from a generic supertype? According to this article, it looks like I should be able: http://www.ibm.com/developerworks/java/library/j-djc05133.html. However, when I do something similar in my application, I get the following error: "Cannot refer to the type parameter T as a supertype." Does anyone know if I...

how to call method without knowing the class name?

I have defined two classes below. public class junk { private BigInteger a = BigIngeger.valueOf(1), b=BigInteger.valueOf(2), c; public void DoSomething(){ c = a.add(b); } // ... other stuff here } public class junkChild extends junk{ private BigDecimal a = BigDecimal.valueOf(1), b=BigDecimal.valueOf(2), c;...

SQL Server 2005 + JavaEE application on one computer in production

We have project with a server witch have about 3000 requests at day from client. 30-40 on-line users. And smth about 30-40Gb data increase per year. And system should be on-line 24x7. Where can we locate the SQL server better? On one computer with JavaEE container or on standalone computer? What pros and cons on this ways? ...

how to use the image file located in local drive, for printing it in jsp page or servlet page?

I want to display the image located in my local drive. I am using sun java app server 8. For example If I generate a file abc.jpg dynamically and store it in c:\abc.jpg, then how could I use it in jsp or servlets? How to display it in the jsp or servlet pages? I know giving the path c:\abc.jpg in coding to display image wont work , becau...

Inject dependency into static field

I want to make template engine available in servlets. The concrete template engine implementation should be changeable behind the TemplateEngine interface. With usual dependency injection it could look like this: public abstract class BaseServlet extends HttpServlet { private TemplateEngine templateEngine; public void setTempl...

setContextClassLoader slows down drastically when called concurrently

I have pin pointed a bottle neck in my application, it seems to me that it boils down to a call to Thread::setContextClassLoader. Basically I was forced to mess around with the thread's context class loader due to issues with 3rd party libraries (see this question to understand why). The solution I picked was to my knowledge the comm...

is it possible to track or store the visited or clicked urls in webpages created using servlets and jsp?

I created a webpage contains more than 10 links . is it possible to store the clicked urls or visited in my database or file . I have developed webpage using servlet. It is just a page with 10 links. ...

How to right align buttons on a HorizontalPanel (GWT)

Hello, I am trying to implement a simple dialog. I would like to have OK and cancel buttons aligned right at the bottom of the dialog. I embed the buttons into the HorizontalPanel and try to set horizontal alignment to RIGHT. However, this does not work. How to make the buttons align right? Thank you. Here's the snippet: private Widget...

Apache vfs: fetch latest changed file of a directory (sftp)

Hello, I am trying to pull the latest file out of a directory, which is located on a sftp server. The way I do it right now is more or less: public FileObject getLatestFile(String directory) throws FileSystemException { FileObject fo = fsManager.resolveFile(this.host+directory, fsOptions); FileObject latestFile = null; long...

BlazeDS : what ARE those standard security fault codes ?

Hi, I'm trying to write a Flex client that interacts with a Spring-Flex java application. I would like to catch (the flex equivalent of) SecurityExceptions and Display an error page if the user was trying to do something they aren't allowed to do Pop up a login box if the user wasn't logged in According to the Spring-Flex docs, ...

How to make ThreadPoolExecutor's submit() method block if it is saturated?

I want to create a ThreadPoolExecutor such that when it has reached its maximum size and the queue is full, the sumbit() method blocks when trying to add new tasks. Do I need to implement a custom RejectedExecutionHandler for that or is there an existing way to do this using standard java library? ...

Reflection to access advanced telephony features

I am trying to use reflection to access some advanced features of the telephony api not published. Currently I am having trouble instantiating a serviceManager object that is needed to get the "phone" service as a binder which I can then use to instantiate a telephony object which is needed to make a call, end call, etc... currently wh...

Specify the supertype of a class upon instantiation/declaration?

Is it possible to specify the parent of a class when I instantiate/declare that class? For example, can I do something similar to this: MonitoredDevice<DeviceTypeToExtend> device = null; And then from that statement, the MonitoredDevice class would extend from the type parameter DeviceTypeToExtend. Now, I know that you can't use type ...

Do multiple import statements in a program affect performance?

I heard that using multiple import statements in a program affects its runtime performance. Is this true? If so, why? ...

Downloading sent mails from Yahoo, Gmail and Hotmail

I am doing an Android application and I want to get the last 25 sent mails from a certain email account. For Gmail I might use http://g4j.sourceforge.net/ and there is Mail Web Service API for Yahoo at http://developer.yahoo.com/mail/. But I couldn't find something to do it with Hotmail. Do you know if it is possible? Also I am worri...

java: list thread locals?

Is there a way to list TheadLocals bound to a thread? Ideally I could access the Thread.threadLocals map, but it is package protected. The reason I need this is I need to inspect threads as they are returned to a thread pool to ensure the ThreadLocals have been properly cleaned up. Perhaps there is another way to do this? ...

Strategy for cross-language (java and c#) object serialization

I'm working on a project where I'll need to serialize some data in a java 6 app and deserialize it a c# 2.0 app. Is there a strategy or something already in existence I can look at that would allow me to do this with these two languages? I'm guessing they both support XML serialization but I really need it to be binary serialized. ...

How to pass an XML document as a parameter to an XSL transform in java (oracle xdk)?

I'm trying to pass an XML document to an XSLT stylesheet as a parameter. I believe the code is using the oracle XDK for transformations (it's using JDK 1.4.2, and Spring, and I'm new to the codebase, so I'm not sure what is getting loaded in the end). In my first attempt, I just created a document object and set this as the parameter on ...

Private variables/methods in anonymous class?

Hello. I have created an anonymous class in which I declare a few variables and methods. My java teacher tells me to make these private. I don't see how changing the modifier makes any difference since these variables and methods are private to the anonymous class anyway, so I prefer to have no modifier at all. Who is right and what make...