java

Setting java.util.logging destination programmatically

I'm using java.util.logging for logging and tracing purposes. How can I within a Java application dynamically set the file to which the log should be written. ...

Load Webpage with login in java

Hi community, I have a webpage http:/ /www.somesite.de This webpage gives me a file I want to download, but before I can do it I have to login with a username and a password. Can anyone tell me where I have to look for best practices for such a problem? Thanks in advance Sebastian ...

Upload File in Ajax by Wicket

I want to upload a file by ajax in wicket.what should I do. beacuse it Seems that wicket does not support this feather. ...

JPA EntityManager deletes all records in database

I have one Servlet that does insertion into my database. This is working fine. A second Servlet displays what the first one has inserted, however whenever I run the displaying Servlet, all records in all my tables are being deleted! My JPA implementation is EclipseLink and the db is MySQL. Is it possible that the way I retrieve a Entity...

Wait for Garbage Collection of a specific object

I was just digging around in the commons-io library and found this: Keeps track of files awaiting deletion, and deletes them when an associated marker object is reclaimed by the garbage collector. This can be found in the documentation for the FileCleaningTracker object. Now I am just curious how I can do this by myself? How can my ...

How to remove a line from text file based on "studentId"?

Hi there I am really interested to have a method that can remove a line from text file based on "id number", but i don't know how to achieve this any help please, thanks. That is what i have got so far: // students.txt file 1111111,John Smith 7777777,Dave Smith // class Student import java.io.*; public class Student implements Ser...

File modification date in Java

I set the modification date of a file created in Java to a specific number. When I read out that value on Windows, I get the same value out. However, on Linux (ubuntu) I get a different value. The value for File.lastModified() is off by 9 hours, yet when I look a the file properties I see that it's off by 1 hour only. I am expecting the ...

Returning char array from java to C - JNI

I have a object store in Java. My C program stores data (in form of char array) in java. Now I wish to retrieve data from my store. I cannot find any function call that returns me an char array. How can I do this? ...

java create a file (not a folder)

Perhaps somewhat embarassing, but after some hours I still cannot create a file in Java... File file = new File(dirName + "/" + fileName); try { // --> ** this statement gives an exception 'the system cannot find the path' file.createNewFile(); // --> ** this creates a folder also named a directory with the name fileName ...

JMS Performance: BytesMessage vs ObjectMessage

In terms of JMS performance, I have read that ObjectMessage should be avoided for performance reasons. How bad are ObjectMessage performance-wise? Should I serialize to a BytesMessage and manually deserialize? ...

applications running on java 1.4 but windows server says new java updates available.

I am running applications on my windows server that run on Java 1.4 In the bottom right hand corner, Java wants me to update. Is this going to update to Java 1.6, or do these auto-updates only put out non breaking patches and my system will still be Java 1.4 Any insight would be great! Thanks. ...

Glassfish/Toplink and sqljdbc.jar retrying forever on broken db-connection

I'm using Glassfish and Toplink together with an MS-SQL-Server, thus sqljdbc4.jar is used for connecting to the database. When the database is not available (DB server is down), the CPU usage rises to 100% and Glassfish keeps on trying to connect forever. My log fills up rapidly with the following messages: FINE: TDSChannel (ConnectionI...

Spring Injecting into Struts RequestProcessor

I wrote a custom Struts RequsetProcessor for my application that is manually fetching some references from Spring. It is working just fine, but I would like to do the "right" thing and inject everything I need at construction time. Is there a way to define a custom Struts RequestProcessor in a way that I can inject Spring objects into ...

Sonar project integration

Hi Ladies and Gentlemen, We've quite big project with own build framework, based mostly on Java (however other languages exist). We'd like to use Sonar Hudson plugin to graphically present various code metrics. How do we do this? Do we need to change project structure and bring it to maven or there is a workaround to just specify wh...

java gui changing picture causes heapspace error

I have a java programme than when a button is clicked it updates the image on screen to the according image. this will work for the first 15 or so clicks then it causes a java heapspace error. I think it is because of the way I am updating the jpanel that contains the bufferedimage but not sure what the reason is. My code to get make the...

Do Applet JSObject javascript calls serialize?

Do applet javascript calls serialize in any proper way? I'm considering implementing a model in which two threads send off javascript commands. One responds to requests from the browser (js), and the other hits the browser periodically. My question is this: what happens if these two javascript requests collide? I'm worried about concurr...

JPA + Hibernate + autocommit

Does anybody know why I get this warning when I turn off the auto-commit in JPA configuration file? Using this setting : <property name="hibernate.connection.autocommit" value="false"/> generates this warning : 2009-08-04 09:54:10,621 [main] WARN org.hibernate.ejb.Ejb3Configuration - hibernate.connection.autocommit = false break the...

Calling a .Net Window-based application using Runtime.getRuntime().exec from a Spring Controller running on Tomcat.

I am calling an exe file called myapp.exe via a Spring Controller; here is the code in the controller: Runtime.getRuntime().exec("D:\vmd\apps\myapp.exe"); myapp.exe is a C# .NET application. If I click directly on myapp.exe using Windows Explorer, the application opens up and runs; however, if I call the command through a Spring Control...

Scale an image which is stored as a byte[] in Java

I upload a file with a struts form. I have the image as a byte[] and I would like to scale it. FormFile file = (FormFile) dynaform.get("file"); byte[] fileData = file.getFileData(); fileData = scale(fileData,200,200); public byte[] scale(byte[] fileData, int width, int height) { // TODO } Anyone knows an easy function to do this? ...

Configuring Tomcat to only raise one Servlet per application

According to my understand, Tomcat is allowed to raise as many copies of a servlet as it wishes in order to service requests. This forces my servlets to have no heavyweight state, and instead store all state in the (singleton) servlet context. Is it possible to configure Tomcat to treat my servlets as singletons, and always raise exact...