Java Program Using Apache POI Giving Exceptions
May 13, 2015
I am having some serious difficulty getting my project off the ground. I have the following code:
FileInputStream file = new FileInputStream(new File("src/retestchecker/test_sheet.xlsx"));
//Get the workbook instance for XLS file
XSSFWorkbook workbook = new XSSFWorkbook(file);
//Get first sheet from the workbook
XSSFSheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(0);
Cell x = row.getCell(3);
System.out.println(x);
Everything is properly imported, etc etc.. But I am getting this error and I am not sure what it means:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
at retestchecker.RetestChecker.main(RetestChecker.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
[Code] .....
Java Result: 1
I am using Netbeans and the latest version of Apache POI that was released May 11, 2015.
The line 23 that the error refers to is this line:
XSSFWorkbook workbook = new XSSFWorkbook(file);
View Replies
ADVERTISEMENT
Mar 5, 2014
Why this extremely simple program seems to be giving me a negative value for amount of calculations done within one minute ( Just using it as a bit of fun to see how different computers in the office perform).
Java Code:
class Benchmark {
public static void main(String[] args) {
long endTime = System.currentTimeMillis() + 60000;
int count = 0;
for (int i = 0; System.currentTimeMillis() < endTime; i++) {
double x = Math.sqrt(System.currentTimeMillis());
count = i;
}
System.out.print(count + " calculations per minute");
}
} mh_sh_highlight_all('java');
I am getting results between -2.1billion and -3.4billion which to me would make sense since they are not the best computers in the world but I would be expecting a positive value?
View Replies
View Related
Apr 16, 2013
I keep getting an error in my browser:
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
[Code] .....
I see the file "myApache.log" got created but there's no info in it when i re-test the error, I have other existing appenders and categories in this same file which do give output so I know it has nothing to do with the file or the path itself.
View Replies
View Related
Sep 28, 2014
I am having trouble figuring out why java is giving me an error for the symbols. I will post the errors below the code.
Java Code: import java.util.Scanner;
public class ShelbyHarms_3_02 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
[code]....
View Replies
View Related
May 15, 2014
Problem: On the form window, after pressing the button, it doesn't give any error and doesn't give any output. It doesn't reply and i have to stop compiling to exit. Why does the IDE do that, is it about my Java codes or Form Window codes ? ( I have two classes named Lexical.java and window.java. Working with Eclipse)
Details: I am working on a project that makes Lexical and Syntax analiysis of commands written in SQL Language. My form is in the attachment. If will be necessary i'll put my codes too.
Attached image(s)
View Replies
View Related
Dec 12, 2014
This is what I wrote and I get this eror : Points to Ponder for Java Null Pointer Exceptions
public class Line{
private Punkt2d pStart;
private Punkt2d pEnde;
public Line(Punkt2d pStart, Punkt2d pEnde) {
this.pStart = pStart;
this.pEnde= pEnde;
[Code] ....
Erorr:
Exception in thread "main" java.lang.NullPointerException
at Line.getLength(Line.java:38)
at Aufgabe_6_1.main(Aufgabe_6_1.java:7)
View Replies
View Related
Aug 14, 2014
I want to read json file as follow;
{
"M": {
"row": [
{
"col1": "c00"
},
{
"col1": "c10",
"col2": "c11"
},
{
"col1": "c20",
"col2": "c21",
"col3": "c22"
}
]
}
}
Next to reading I need to assign to two dimensional array, but without giving "col1","col2","col3" a lot.
The array is for example, Array[3][] = {{"c00"},{"c10","c11"},{"c20","c21","c22"}};
View Replies
View Related
Jan 19, 2015
I'm trying to learn how to read from, and write to, Excel files. I'm looking at this link : [URL] ....
It seems like there are some Apache dependencies. So, I go here : [URL] .....
I downloaded the zipped file from the first link. Now what? I don't see any .exe file, or any way of installing it. How do I install it, or run it, or whatever? What is the next step here?
View Replies
View Related
Sep 2, 2014
I'm trying to read a .xlsx file using Apache Poi on Eclipse and store the data into an ArrayList.
My code :
import org.apache.poi.ss.usermodel.*;
import java.io.*;
import java.util.*;
public class parseReadFiles
{
public static void main(String[] args) {
[Code] ....
I keep getting a FileNotFoundException: Users/Divjot/Desktop/first.xlsx (No such file or directory). I've tried different combinations of file names and paths but can't get the program to find it. Should the file be stored in a special place or should the class path be different?
View Replies
View Related
Feb 18, 2014
I've got this annoying error message when trying to import:
import org.apache.commons.codec.binary.Hex.encodeHex;
"Import org.apache.commons.codec cannot be resolved", which after searching seems to be a somewhat common problem. The solution being to go to: FileUpload - Home and download some jar file and add it to the /web-inf/lib folder. yet the error persists even after adding the jar file in "add external jar files" and restarting eclipse.
The jar file I added is called "commons-fileupload-1.3.1.jar" which is the only one I could find in the zip file. I've searched around looking at numerous threads about the issue, several of them sadly several years old, with no success.Surely installing a library to eclipse shouldn't be this complicated?
View Replies
View Related
May 20, 2014
I'm using apache POI to input data from a excel database. I have a method that is supposed to count the number of rows containing data so I can use that number to initialize an object array. It's returning one more than the actual number of rows and I can't figure out why.
public int getDataRange() throws IOException{
int rowCount = 0;
Iterator<Row> rows = sheet.rowIterator();
while(rows.hasNext()){
HSSFRow row = (HSSFRow) rows.next();
rowCount++;
[Code] .....
I get an array index out of bounds exception at the highlighted line.
View Replies
View Related
Feb 19, 2014
I am developing an dashboard application in Java, JSTL, MySql, Apache Tomcat 6.I have the below files
1. Dashboard.java (model)
2. DashboardDAO.java (dao)
3. DashboardController.java (Controller)
//Source
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
String forward = "";
forward = LIST_DASHBOARD;
HttpSession session = req.getSession(true);
session.setAttribute("dboard", dao.getAlldashboard(req));
setMasterInfo(req);
RequestDispatcher view = req.getRequestDispatcher(forward);
view.forward(req, res);
[code]....
It works in the first time. But, after sometime the data is not retrieved and display empty screen. Once, i stop and start the server again, the data is getting retrieved again. But, later when we refresh the empty page is getting displayed again.
View Replies
View Related
Dec 10, 2014
I'm currently using TextPad or command prompt to compile and run my programs, and as usual I am not having any luck importing external libraries, in particular apache commons.
I couldn't see any particularly obvious settings in TextPad to set a library or class path (which is annoying as I really like the program), so I jumped back to cmd prompt to run it from there. Aaaaaand i don't understand .
This is my file structure at present:
/mainProject //includes .java and .class files, and where I've successfully placed .jar files before.
The apache commons zip file was extracted here, making:
/mainProject/commons-lang3/apidocs/orgs/apache/commons/<folders> //the commons-lang3 folder contains the jars I'm navigating to the /mainProject folder in cmd prompt and typing (amongst many other things) javac -cp /mainProject/commons-lang3 MonsterGame.java //with the -cp being pointed at the folder the .jar is in i've tried pointing it at the root folder where the import statement begins in the code (ie mainProject/commons-lang3/apidocs), tried moving the .jar files to the mainProject folder (pointing -cp at it) and more. No luck.
it seems everytime i try to import a new library something goes wrong..... its become a bit of a stumbling block to be honest. I seem to spend most of my time dealing with the 'administrative' side of coding (that was the politest way i could put it ), am I not doing it right?
I've read I'm supposed to include the .jar in the classpath, not just the directory. is this correct? (it still doesn't work...!)
View Replies
View Related
Mar 17, 2012
i am getting the following errors.
Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.<init>(Unknown Source)
at java.io.InputStreamReader.<init>(Unknown Source)
at ToHtml.printStyles(ToHtml.java:215)
at ToHtml.printInlineStyle(ToHtml.java:199)
[code]...
View Replies
View Related
Sep 17, 2014
I'm using Apache Poi to create an Excel file from a JTable.
I want to open the file directly in Excel, rather than first write it to disk and then open it from the disk.
FileOutputStream output = new FileOutputStream( StolleExcel.xls" );
workBook.write( output );
Desktop dt = Desktop.getDesktop();
dt.open( new File( "StolleExcel.xls" ) );
output.close();
Is there a temporary way of saving the Excel object then just opening it with Excel, so the user can save or edit whatever they want?
View Replies
View Related
Feb 6, 2015
I am testing a code given by my lecturer and the output it gives me are all question marks? Heres the code:
package assignment;
import java.util.Random;
public class DeckOfCards { // begin DeckOfCards data type
// playing cards of deck of cards
private PlayingCard[] deck;
[code]....
View Replies
View Related
Feb 20, 2014
I have just tried to learn java this week [COLOR="#000000"]and I am being held back by this once installed java jdk I nav to the java file and the bin file and then the javac file to find that the below tab does not exist
A new window should pop up giving the properties of the javac, there should be an attribute called Location..I can see the location option in my documents but in no other folder
View Replies
View Related
May 7, 2014
I am having issues with the first part of my program. When I got to display what is in the textfile, it only gives me one name two times. I cannot figure out what to do with my outer loop in order for it to read and output the entire data file.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.util.Scanner;
import java.io.*;
import java.text.*;
import java.math.*;
import java.util.StringTokenizer;
[Code] ....
View Replies
View Related
Nov 22, 2014
I am just learning how to throw exceptions, and I'm stuck on the last part,
Here is where I created the exception that receives a string consisting of ID and wage.
public class EmployeeException extends Exception
{
public EmployeeException(String Employee)
{
super(Employee);
}
}
Here is where I created the Employee class with the two fields. I also believe I am throwing the exception if the hourly wage is < $6 or > $50.
public class Employee
{
int idNum;
double hourlyWage;
public void Employee(int empID, double empWage) throws EmployeeException
{
idNum = empID;
hourlyWage = empWage;
[Code]...
Now, I need to write an application with three employees and display a message when an employee is successfully created or not. This is what I have so far... I'm trying to get it to work with one employee, and then I can easily go back and add two more.
import javax.swing.*;
public class ThrowEmployee
{
public static void main (String[] args)
{
try
{
Employee one = new Employee(542, 15.20);
}
[Code
The current compile error that I'm receiving is: ThrowEmployee.java:12: error: constructor Employee in class Employee cannot be applied to given types;
Employee one = new Employee(542, 15.20);
^
required: no arguments
found: int,double
reason: actual and formal argument lists differ in length
1 error
I have public void Employee(int empID, double empWage) in my Employee class, so why is it saying that no arguments are required? Not sure if I'm missing a step with throwing exceptions, because this error has always been a simple fix when I've come across it in the past?!?
View Replies
View Related
Apr 14, 2014
In my EJB modules, to prevent that any JPA exception is ever thrown, I check the condition that would cause the exception beforehand. For example, the exception javax.persistence.EntityExistsException is never thrown because, before persisting the entity, I check if such primary key already exists in the DB. Is it the right way to do this?
Another approach is too allow the JPA exceptions to be thrown and catch them in a try-catch block, and then throw my custom exception from the "catch" block. However it requires to call EntityManager.flush () at the end of the "try" block. Otherwise the exception throw could be deferred and never be caught by my block.
View Replies
View Related
May 6, 2015
I have an app that is randomly hanging it doesn't give any error information when it hangs.
Is there at way to see what's going on when it hangs? e.g. the methods that are being called, where is the program execution at..
View Replies
View Related
Jul 31, 2014
There are times that my methods need to report the caller about many kinds of errors, represented as checked exceptions. This makes my methods look like very convoluted. It happens mostly when I work with stateless EJBs and databases. Sometimes I end throwing even 8 different exceptions! Are they too many?
Many of them inherit from common exceptions, so I've been tempted to throw the parent classes. But I've quickly discarded that option because I've read that it's a bad practice, since a method may throw only a subset of the children of that parent class, not all.
Finally, I've studied these possibilities:
1. Throwing the parent class (mentioned above).
2. Throwing a common exception with an error ID or code as message.
3. Throwing a common exception with an enum as member, as if it were an ID or code (safer than the #2).
All them show the same defect that the #1. However it's more a conceptual problem than a technical one, because my callers always use the same mechanism to treat every "specialization" of the same exception, without worrying about if the method really can return it or not.
View Replies
View Related
Aug 3, 2014
I want to test that a function has no any exceptions.In C++ and Google Test Framework (GTest) it will look like this:
ASSERT_NO_THROW({
actual = divide(a, b);
});
How will it look in Java?
View Replies
View Related
Oct 29, 2014
I'm writing a program that accepts three doubles from the user, and performs calculations on them. I want to be able to handle input mismatch exceptions on each individually (i.e., if the user enters a double for the first, then a letter for the second, I'd like to be able to keep the value entered for the first, and only require that the user try again with the second, then the third, etc.)... I tried putting each input instance into its own try/catch blocks, but it always goes back to #1 when an invalid input is entered. Right now, I have all three in one try/catch:
Java Code:
package com.itse2317;
import java.util.Scanner;
import java.util.InputMismatchException;
class Triangle
{
public static double side1 = 0.0, side2 = 0.0, side3 = 0.0;
[code]...
View Replies
View Related
Aug 4, 2014
Create an array that will store 7 temperatures.
Populate the array with 7 random temperatures from 1 to 100 degrees. (hint use a for loop and a Random number Generator)After the temperatures are in the array, calculate the average of the temperatures in the array.
Print out the average.Print out each temperature in a statement comparing it to the average such as:
The average temperature is 48.94
Temperature 1 is 5.0 and is below average.
Temperature 2 is 67.8 and is above average.
import java.util.Random;
public class ArrayOfTemperatures
{
public static void main(String[] args) {
// Declare an array
int[] randomtemps = new int[7];
temps[0] = 45;
[code]....
View Replies
View Related
Aug 22, 2014
I am having problems with writing a simple program to see if a number is divisible by 6.
public void run() {
println("This program will display all numbers divisible by");
println(" 6 between 1 and 100.");
int x =1;
boolean divide =(x%6==0);
[Code] ....
It is telling that every number is not divisable by 6?
View Replies
View Related