in my program
package com.XSLTTransformation;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import net.sf.jxls.exception.ParsePropertyException;
import net.sf.jxls.transformer.XLSTransformer;
public class XSLTTransformation {
public static void main(String[] args) {
Collection<Employee> staff = new HashSet<Employee>();
staff.add(new Employee("Derek", 35, 3000, 0.30));
staff.add(new Employee("Elsa", 28, 1500, 0.15));
staff.add(new Employee("Oleg", 32, 2300, 0.25));
staff.add(new Employee("Neil", 34, 2500, 0.00));
staff.add(new Employee("Maria", 34, 1700, 0.15));
staff.add(new Employee("John", 35, 2800, 0.20));
Map<String, Collection<Employee>> beans = new HashMap<String, Collection<Employee>>();
beans.put("employee", staff);
XLSTransformer transformer = new XLSTransformer();
try {
transformer.transformXLS("C:/Users/hussain.a/Desktop/malay/newprojectpocdetails/temp.xls", beans, "C:/Users/hussain.a/Desktop/malay/newprojectpocdetails/proovNYOutput.xls");
} catch (ParsePropertyException e)
{
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
i find this error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/jexl2/parser/Node
at net.sf.jxls.transformer.XLSTransformer.transformWorkbook(XLSTransformer.java:269)
at net.sf.jxls.transformer.XLSTransformer.transformXLS(XLSTransformer.java:221)
at net.sf.jxls.transformer.XLSTransformer.transformXLS(XLSTransformer.java:201)
at com.XSLTTransformation.XSLTTransformation.main(XSLTTransformation.java:27)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.jexl2.parser.Node
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
i have placed the jar which has this class , i am not able to identify real prob
Add commons-jexl.jar to the CLASSPATH as well ;
Try this link :https://stackoverflow.com/a/8286795/1743852
Related
package ReadExcelData;
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ReadandWriteExcel {
public static void main(String []args){
try {
File src = new File("C:\\poi\\ExcelData\\TestExcelData.xlsx");
FileInputStream fis=new FileInputStream(src);
XSSFWorkbook wb=new XSSFWorkbook(fis);
XSSFSheet sh1= wb.getSheetAt(0);
System.out.println(sh1.getRow(0).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(0).getCell(1).getStringCellValue());
System.out.println(sh1.getRow(1).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(1).getCell(1).getStringCellValue());
System.out.println(sh1.getRow(2).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(2).getCell(1).getStringCellValue());
wb.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
Hi,
I Downloaded poi-4.0.0 and added external jar file to my project. After setup of project I created excel file and wrote java program to read from excel file
While run time I am getting error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipFile
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:298)
at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:307)
at ReadExcelData.ReadandWriteExcel.main(ReadandWriteExcel.java:19)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.compress.archivers.zip.ZipFile
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more`enter code here`
You need to add commons-compress-1.18.jar into your project build path.
https://commons.apache.org/proper/commons-compress/download_compress.cgi
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/concurrent/FutureCallback
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at iezon.main.WebSocket.getAllApps(WebSocket.java:21)
at iezon.main.Init.(Init.java:16)
at iezon.main.Init.main(Init.java:27)
Caused by: java.lang.ClassNotFoundException: org.apache.http.concurrent.FutureCallback
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
My current code is:
package iezon.main;
import org.json.JSONArray;
import org.json.JSONObject;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import iezon.interfaces.options.InterfaceController;
public class WebSocket {
public WebSocket() {
}
public void getAllApps() {
try {
HttpResponse<JsonNode> request = Unirest.get("https://iezontechnologywebapp.000webhostapp.com/api/store/get").asJson();
JSONArray response = request.getBody().getArray();
for (int i = 0; i < response.length(); i++) {
JSONObject object = response.getJSONObject(i);
// TODO: Load apps properly this is just a test dialog to show they loaded
InterfaceController.showDialog(new Object[] {
object.getString("name"),
object.getString("description")
}, "Apps loaded");
}
} catch (UnirestException e) {
e.printStackTrace();
}
}
}
I have tried adding httpclient-4.3.3.jar to the buildpath as well as commons-io-2.5.jar but neither has fixed the issue, I have checked documentation but doesn't say I need any other libraries to run Unirest
I have no idea way I get this error. The code is from JXLS own example and the Jars are downloaded from there page.
Error code:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.jxls.util.TransformerFactory.loadPoiTransformer(TransformerFactory.java:85)
at org.jxls.util.TransformerFactory.getTransformerClass(TransformerFactory.java:69)
at org.jxls.util.TransformerFactory.createTransformer(TransformerFactory.java:27)
at org.jxls.util.JxlsHelper.createTransformer(JxlsHelper.java:250)
at org.jxls.util.JxlsHelper.processTemplate(JxlsHelper.java:108)
at test_excel.ObjectCollectionDemo.main(ObjectCollectionDemo.java:32)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Workbook
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more
Referenced Libraries:
/slf4j-1.7.25/slf4j-api-1.7.25.jar
/slf4j-1.7.25/slf4j-jdk14-1.7.25.jar
/jxls-2.4.1 2/dist/jxls-reader-2.0.3.jar
/jxls-2.4.1 2/dist/jxls-poi-1.0.13.jar
/xls-2.4.1 2/dist/jxls-jexcel-1.0.6.jar
/jxls-2.4.1 2/dist/jxls-2.4.1.jar
Main code:
package test_excel;
import org.jxls.common.Context;
import org.jxls.util.JxlsHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class ObjectCollectionDemo {
private static Logger logger = LoggerFactory.getLogger(ObjectCollectionDemo.class);
public static void main(String[] args) throws ParseException, IOException {
logger.info("Running Object Collection demo");
List<Employee> employees = generateSampleEmployeeData();
try(InputStream is = ObjectCollectionDemo.class.getResourceAsStream("object_collection_template.xls")) {
try (OutputStream os = new FileOutputStream("object_collection_output.xls")) {
Context context = new Context();
context.putVar("employees", employees);
logger.info("OK so far...");
JxlsHelper.getInstance().processTemplate(is, os, context);
}
}
}
public static List<Employee> generateSampleEmployeeData() throws ParseException {
List<Employee> employees = new ArrayList<Employee>();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MMM-dd", Locale.US);
employees.add( new Employee("Elsa", dateFormat.parse("1970-Jul-10"), 1500, 0.15) );
employees.add( new Employee("Oleg", dateFormat.parse("1973-Apr-30"), 2300, 0.25) );
employees.add( new Employee("Neil", dateFormat.parse("1975-Oct-05"), 2500, 0.00) );
employees.add( new Employee("Maria", dateFormat.parse("1978-Jan-07"), 1700, 0.15) );
employees.add( new Employee("John", dateFormat.parse("1969-May-30"), 2800, 0.20) );
return employees;
}
}
Looks like you need poi-3.XX.jar in your class path - see here.
I was watching this tutorial on making games using java and I was on the part where we import music to our game. However, when I try to load the sounds using a method created in this class:
package main;
import java.util.HashMap;
import java.util.Map;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;
public class AudioPlayer {
public static Map<String, Sound> soundMap = new HashMap<String, Sound>();
public static Map<String, Music> musicMap = new HashMap<String, Music>();
public static void load(){
try {
soundMap.put("click_sound", new Sound("res/clickSound.ogg"));
musicMap.put("music", new Music("res/background_Music.ogg"));
} catch (SlickException e) {
e.printStackTrace();
}
}
public static Music getMusic(String key){
return musicMap.get(key);
}
public static Sound getSound(String key){
return soundMap.get(key);
}
}
i get an error that says this:
Exception in thread "main" java.lang.NoClassDefFoundError: com/jcraft/jorbis/Info
at org.newdawn.slick.openal.OggInputStream.<init>(OggInputStream.java:35)
at org.newdawn.slick.openal.OggDecoder.getData(OggDecoder.java:311)
at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:835)
at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:793)
at org.newdawn.slick.Sound.<init>(Sound.java:87)
at main.AudioPlayer.load(AudioPlayer.java:18)
at main.Game.<init>(Game.java:45)
at main.Game.main(Game.java:160)
Caused by: java.lang.ClassNotFoundException: com.jcraft.jorbis.Info
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 8 more
AL lib: (EE) alc_cleanup: 1 device not closed
have I wrote something wrong? i imported the correct external jars and did everything that said in the tutorial. However, I keep getting this error?
I am doing a project in java called visual speech recognition . while iam trying to run the below code in eclipse indigo..
package main.java.edu.lipreading;
import com.googlecode.javacpp.BytePointer;
import com.googlecode.javacv.cpp.opencv_core;
import main.java.edu.lipreading.vision.AbstractFeatureExtractor;
import main.java.edu.lipreading.vision.NoMoreStickersFeatureExtractor;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.websocket.WebSocket;
import org.eclipse.jetty.websocket.WebSocketHandler;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.logging.Logger;
import static com.googlecode.javacv.cpp.opencv_core.CV_8UC1;
import static com.googlecode.javacv.cpp.opencv_core.cvMat;
import static com.googlecode.javacv.cpp.opencv_highgui.cvDecodeImage;
/**
* Created with IntelliJ IDEA.
* User: Sagi
* Date: 25/04/13
* Time: 21:47
*/
public class WebFeatureExtractor extends Server {
private final static Logger LOG = Logger.getLogger(WebFeatureExtractor.class.getSimpleName());
private final static AbstractFeatureExtractor fe = new NoMoreStickersFeatureExtractor();
public WebFeatureExtractor(int port) {
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
addConnector(connector);
WebSocketHandler wsHandler = new WebSocketHandler() {
public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
return new FeatureExtractorWebSocket();
}
};
setHandler(wsHandler);
}
/**
* Simple innerclass that is used to handle websocket connections.
*
* #author jos
*/
private static class FeatureExtractorWebSocket implements WebSocket, WebSocket.OnBinaryMessage, WebSocket.OnTextMessage {
private Connection connection;
public FeatureExtractorWebSocket() {
super();
}
/**
* On open we set the connection locally, and enable
* binary support
*/
#Override
public void onOpen(Connection connection) {
LOG.info("got connection open");
this.connection = connection;
this.connection.setMaxBinaryMessageSize(1024 * 512);
}
/**
* Cleanup if needed. Not used for this example
*/
#Override
public void onClose(int code, String message) {
LOG.info("got connection closed");
}
/**
* When we receive a binary message we assume it is an image. We then run this
* image through our face detection algorithm and send back the response.
*/
#Override
public void onMessage(byte[] data, int offset, int length) {
//LOG.info("got data message");
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
bOut.write(data, offset, length);
try {
String result = convert(bOut.toByteArray());
this.connection.sendMessage(result);
} catch (Exception e) {
LOG.severe("Error in facedetection, ignoring message:" + e.getMessage());
}
}
#Override
public void onMessage(String data) {
LOG.info("got string message");
}
}
public static String convert(byte[] imageData) throws Exception {
opencv_core.IplImage originalImage = cvDecodeImage(cvMat(1, imageData.length, CV_8UC1, new BytePointer(imageData)));
List<Integer> points = fe.getPoints(originalImage);
if(points == null)
return "null";
String ans = "";
for (Integer point : points) {
ans += point + ",";
}
return ans;
}
/**
* Start the server on port 999
*/
public static void main(String[] args) throws Exception {
WebFeatureExtractor server = new WebFeatureExtractor(9999);
server.start();
server.join();
}
}
i am getting this error..
Exception in thread "main" java.lang.VerifyError: class org.eclipse.jetty.server.nio.AbstractNIOConnector overrides final method newBuffer.(I)Lorg/eclipse/jetty/io/Buffer;
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at main.java.edu.lipreading.WebFeatureExtractor.<init>(WebFeatureExtractor.java:33)
at main.java.edu.lipreading.WebFeatureExtractor.main(WebFeatureExtractor.java:118)
i got dis code from https://github.com/sagioto/LipReading/blob/master/lipreading-core/src/main/java/edu/lipreading/WebFeatureExtractor.java..
can anyone help me plz..
java.lang.VerifyError can happen if you're running against a different version of a library than the code was compiled against.
Looking in the github repository, I see the files are dated 25 April 2013. Apparently, Jetty has received an update during these last 10 months. Find the version of Jetty that was current on that date and try again.