My code compiled fine with the following command: javac -cp “../lib/*” AvroReader.java (lib is where i put my jar files) At run time I get a ClassNotFoundException on the following line: DatumReader<?> dtmrdr = new GenericDatumReader(); It says it can’t find org.apache.avro.generic.Gen…
Tag: java
Can’t start Eclipse – Java was started but returned exit code=13
I am trying to get my first taste of Android development using Eclipse. I ran into this problem when trying to run Eclipse, having installed version 4.2 only minutes ago. After first trying to start Eclipse without any parameters to specify the Java VM, I got an error message saying it couldn’t find a J…
How can I avoid the Warning “firstResult/maxResults specified with collection fetch; applying in memory!” when using Hibernate?
I’m getting a warning in the Server log “firstResult/maxResults specified with collection fetch; applying in memory!”. However everything working fine. But I don’t want this warning. My code is My query is Answer Reason for this warning is that when fetch join is used, order in result …
Include field name inside error message using Hibernate Validator
I’m using Hibernate Validator 4.2.0.Final and I’m looking for the simplest way to include class field name in my error message. What I found is the following thread Using a custom ResourceBundle with Hibernate Validator. According to this I should create my custom annotation for each constraint an…
How to offer download of local PDF file in Java?
I have JBoss running as application server and somewhere on my HD there is a PDF file, that gets created when the user clicks on a specific action. Let’s say the file is here: C:/PDF/doonot/10.07.2012/doonot.pdf. How can I offer this file as download? I already did it for a CSV file, but I don’t k…
Multiline text in Excel cells
I’m trying to write multiline text to excel cells. But when I open the document, I see only one line until I double-click it for editing, then it becomes two-lined. Why is it so? Thanks Answer You need to set the row height to accomodate two lines of text. You need to set the wrap text = true to get
My JSON files are too big to fit into memory, what can I do?
In my program, I am reading a series of text files from the disk. With each text file, I process out some data and store the results as JSON on the disk. In this design, each file has its own JSON file. In addition to this, I also store some of the data in a separate JSON file, which stores
Serialization – How to secure a serialized JAVA object?
How can I secure the serialized object if I send the serialized object over the network? I doubt that hackers may interrupt/hack my data. can anyone tell in detail about how to implement this? Answer This presentation give ideas on how effectively attackers can tamper a Java serialized stream: https://www.owa…
How to check if current thread is not main thread
I need to check if the thread running a certain piece of code is the main (UI) thread or not. How can I achieve this? Answer if this returns true, then you’re on the UI thread!
Load RSA public key from file
I’ve generated a private key with: After this I’ve generated a public key with: I want to sign some messages with my private key, and verify some other messages with my public key, using code like this: I found a solution to convert my private key to PKCS8 format and load it. It works with some co…