java

Does ntdll.dll come standard with windows xp and windows vista?

Hello, Does ntdll.dll come standard with windows xp and windows vista? I know that I have it on my windows xp machine, but am not sure that is standard with every machine. The reason I am curious is for the NTQuerySystemInformation function to get CPU usage of a windows xp and/or windows vista system. Thanks, Steve ...

Freemarker template not found

Hi, I'm currently trying to get Freemarker to work with my application using Spring. No matter what I try I keep getting template not found. I am not sure if I have the configuration set up properly, but it never finds my template. Here is my spring bean config: <bean id="freemarkerConfig" class="org.springframework.web.servlet.vie...

Java callback function on every class method

Is there a way in JAVA to call a callback function on every method of my class without having to explicitly do the call?? I don't want to do public void foo() { //some code callBackFunction() } I would like to do public void foo() { //some code } and then the class recognizes that it has to call the callBackFunction() ...

Porting app from tomcat to glassfish

My app have this architecture: struts spring dwr hibernate Now we use apache tomcat 5.5.28. We wanna switch to Glassfish for performance. My question are: anyone know if there are problem for porting using this 4 framework? anyone know a guide for porting? or ... there are an official guide for porting from tomcat to glassfish?...

Wrapping primitives using the new operator vs wrapping primitives using valueOf

What's the difference between, Integer i = new Integer("42"); and Integer i = Integer.valueOf("42"); Thanks. ...

Getting Jersey and Hibernate to work together?

I've got a project which requires both Jersey and Hibernate. Problem is they both use incompatible versions of a Jar file (asm.jar) under the covers. I've looked around Google and it appears that it's possible to get Hibernate to use another facility called Javassist, but when I try to follow the instructions it falls flat. I still get ...

excel file not generating after UTF-8 encoding chosen

This part of my code was creating xls file successfuly FileOutputStream fileOut = new FileOutputStream("c:\\Decrypted.xls"); wb.write(fileOut); fileOut.close(); when other part of the code had this statement ( which was before the above code ) in = new ByteArrayInputStream(theCell_00.getBytes("")); But when I changed it to in ...

java "cannot find symbol" - how to import a file in the same directory?

I have two java files in a directory, neither of them are in a package. I want one of them to be able to reference the other. What is the right way to do this? Currently in Class A, I'm trying to reference class B, and getting this error: [javac] A.java:11: cannot find symbol [javac] symbol : constructor B(java.lang.String) [javac] l...

Java Program Fibonacci Sequence

I am writing a "simple" program to determine the Nth number in the Fibonacci sequence. Ex: the 7th number in the sequence is: 13. I have finished writing the program, it works, but beginning at the 40th number it begins to delay, and takes longer, and longer. My program has to go to the 100th spot in the series. How can I fix this so ...

JSP PageContext from a Groovlet (Groovy Servlet)

I'm trying to use Groovlets in place of JSPs in an integration framework but one of the vendor's libraries relies on the javax.servlet.jsp.PageContext available in a JSP. I found the GroovyPagesPageContext class that's part of Grails for GSPs. Anyway to use Groovy in this situation and have a handle to the jsp PageContext? I have not...

Java date format real simple

how would you write te date if i have a date and all i want is the month and the day like this (mm/dd) and then turn the month like this July, 08 ...

How to split a table's data into two sets based on a column value with Hibnernate mappings?

Suppose there are three tables: Table A (ID, NAME) Table B (ID, NAME) Table A-B (A_ID, B_ID, Boolean_Property) and Table A and B are modeled by classes A and B as follows: public class A { private long id; private String name; // All the B's that belong to A where the boolean property is True Set<B> trueBSet; //...

Invoke a code after all mouse event listeners are executed.

I have created a panel on which a set of objects is drawn. Each of the object is added as a mouse event listener to the panel. As I know, after an event occurs the listeners are notified and the code might be (or is?) executed in several threads. Is it possible to attach a custom code that will be executed after all listeners finish exec...

Impossible to make a cached thread pool with a size limit?

It seems to be impossible to make a cached thread pool with a limit to the number of threads that it can create. Here is how static Executors.newCachedThreadPool is implemented in the standard Java library: public static ExecutorService newCachedThreadPool() { return new ThreadPoolExecutor(0, Integer.MAX_VALUE, ...

Mimicking Zoom bar from Office 2007 in Java (Modified JSlider)

Hi guys, I'm attempting to mimic (or find a preexisting component) that mimics the zoom slider from Word 2007: There are two main differences between this component and a standard Java JSlider: Does not snap to ticks except at 100%, and snaps while you're sliding the bar rather than when you release mouse Slider is not linear the ...

Is it bad practice to change state inside of an if statement?

I wrote some code that looks similar to the following: String SKIP_FIRST = "foo"; String SKIP_SECOND = "foo/bar"; int skipFooBarIndex(String[] list){ int index; if (list.length >= (index = 1) && list[0].equals(SKIP_FIRST) || list.length >= (index = 2) && (list[0] + "/" + list[1]).equals(SKIP_SECOND)){ r...

What is the performance penalty of operator overloading STL

I like STL a lot. It makes coding algorithms very convenient since it provides you will all the primitives like parition, find, binary_search, iterators, priority_queue etc. Plus you dont have to worry about memory leaks at all. My only concern is the performance penalty of operator overloading that is necessary to get STL working. For ...

Java ArrayList Help!

I am working on learning java a little, and i found this question in a java text book on Google books, I have been working on it for a while, and for some reason these seems like it should be simple. Anyone bored and would like to show me what this is suppose to look like in Java code?? (Using ArrayList) Write a program that creates an ...

Help running a jar from within a java program using JarClassLoader

I'm trying to run a jar within a java program and capture its stdout. I want to do this to avoid the JVM startup cost every time the jar is run. What is the simplest way to do this? I started by modifying Java's JarClassLoader and adding a SecurityManager subclass to that to prevent system exits. The JarClassLoader is a subclass of URL...

What security can be added to Java Applets?

When building a Java Applet are there any steps that can be made to prevent a user invoking internal methods? Theoretically most objects can be analysed and methods can be invoked on a client machine. In addition to obfuscation are there any other steps that can help prevent this? My situation is to secure a game where the top score i...