java

How to split file into chunks while still writing into it?

Hi, I tried to create byte array blocks from file whil the process was still using the file for writing. Actually I am storing video into file and I would like to create chunks from the same file while recording. The following method was supposed to read blocks of bytes from file: private byte[] getBytesFromFile(File file) throws IOEx...

JExcelApi currency format on formula cell - file error

Hi guys, I'm writing a spreadsheet with JExcelApi. I have two cells that I want to apply currency formatting to. From reading the API I discovered jxl.write.NumberFormat, which seems to do what I want. In my application I've written: NumberFormat currency = new NumberFormat(NumberFormat.CURRENCY_DOLLAR); WritableCellFormat currencyF...

How to get the compressed image data from JPEG encoder in Java

I want to compress an image using JPEG encoder and instead of writing it to a file I want to pass the compressed data to another application. My problem is that I can compress the data but don't know how to get that compressed image data. I am using this code : out = new FileOutputStream ( filename ); JPEGImageEncoder encoder = JPEGCo...

SWT Table with SWT.VIRTUAL raises StackOverflowError

After recently installing Windows 7 Professional, I'm getting a strange problem removing a TableItem from a populated Table in SWT. It is specific to Windows 7 and to the SWT.VIRTUAL style constant for the table. Consider the following code: table = new Table(parent, SWT.VIRTUAL | Skin.SCROLL_STYLE | SWT.FULL_...

NullPointerException while adding data to the database from online page

Hi All, I am getting a NullPointerException Exception while adding data from the online JSP page. The error description is as follows: javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 0x0 No; nested exception is: org.omg.CORBA.TRANSACTION_ROLLEDBACK: javax.transaction.TransactionRolledbackException: ; ne...

Hibernate query by example (from Spring 3)

I've made my entity classes Adress, Road and County. A Road is in a County and an Adress in on a Road. I would like to list all the Adresses in a County. Therefore, in my AdressService I say: public List<Adress> AllAdresses(County county) { Adress adress = new Adress(); Road road = new Road(); road.setCounty(county); adress.setR...

Spring - StackOverflowError in Bean creation

Hello, I am getting the following error: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:203) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExe...

How to print multiple results in row.

I have a requirement to print my list in two columns along with pagination. I am not able to figure out how will I get 2 records at a time from the list set in the datatable. ...

unable to update CLOB using DBCP connection

Am trying to do update a clob column using a connection object that is retrieved using Apache DBCP connection pooling. Earlier, I've implemented connection pooling using this and it was working fine i.e am able to update CLOB. I switched to DBCP because I was getting java.sql.SQLException: ORA-01000: maximum open cursors exceeded. I've ...

Automatic scaling of consumer pool

We have a web-application that lets the users trigger a request to an external resource. The external resource spends an unspecified amount of time to gather results, so we have to poll it to get updates, and to collect the final results when they are done. We wish to make it so that when the user triggers the request, it gets added to ...

Override Java properties from packages

I am using several packages which are configured by using configuration properties for example org.apache.ws.security.crypto. Normally a single configuration file suffices but I now have a need to override one or more of the properties whenever they are used by code which is called from a particular object instance. I am far from a java...

Commons VFS and Java.net.URL - Adding support for "sftp://" protocol

We're trying to use Apache Commons VFS to access something over SFTP. It claims to support SFTP, however we're getting a MalformedURLException when it starts. Digging around I see that apache vfs is using java.net.URL. However the documentation tells me that it doesn't actually support sftp:// URLs. Protocol handlers for the followin...

I'm new in Java. What to read?

Can you advise me as to some useful Java books to read first? ...

configuring applet options in the <applet> tag

Hello everyone, I must not be very good at googling today. I want to set the option that appears in the applet config that disable applets for being able to access the certificate store of the browser, but not for all the applets, just for one applet. Do you know where can I find all the applets options? Regards ...

Is it possible to change the base millisecond refrence time 1970 to 2008 in java (like JSR-310)

I want to be able to change the base millisecond reference from 1970 to 2008 in java so that I can save space in the database and unique Ids. Preferably with Joda-Time. The upcoming jsr-310 in the supposed java 7 release implements it. In the The Discrete Timeline section of this link it states that the counting of milliseconds has ch...

Java method argument puzzle

Hi. I stumbled upon a very puzzling feature(?) of Java. It seems that using a "new" keyword to replace a method argument kind of shifts that object into a different scope: import java.util.ArrayList; public class Puzzle { public static void main(String[] args) { ArrayList<Integer> outer = new ArrayList<Integer>(); ...

OpenGL/Java Learning Curve

We are looking at speeding up a project with new developers. How long is a typical Java + OpenGl learning curve if anyone has any experience ? The core work is on detailed globe visualization. ...

How to shutdown a servlet container from within a servlet?

Is there a portable way to request a Servlet container to shutdown gracefully, from within a servlet? By portable I mean a technique that will work on all standard compliant containers (Tomcat, Jetty, Winstone, etc). Note that this is the opposite of the Servlet.destroy() method, which gets called when the container is taking the servl...

How to build HQL query, thats joins subtables marked LAZY, automatically?

I have some entity: public class Album extends GenericAuditedEntity { @OneToMany(fetch = FetchType.LAZY) private Set<Item> itemSet = new HashSet<Item>(); } And when i run HQL like this: em.createQuery("select a from Album a").getResults() it produses many SQL queries: One for select data from Album's table. Smth like thi...

Advantages of using Rhino (mozilla's rhino)

I've been reading about Rhino as a useful way to implement JavaScript inside my Java code. After reading for a while, searching in google and here, I couldn't find a real reason for which I would use JavaScript inside Java. Could you point some real world advantages you find on using Rhino for a regular Java application? ...