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?
Related
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 am working on a project to generate BIRT reports in PDF format. The application is not meant to be a web application. I tried to follow the Report Engine API example on this link http://wiki.eclipse.org/Simple_Execute_(BIRT)_2.1 but I get an error when I run (Run as -> Java Application) the code. My code is as below.
My code is as follows:
package birt.classicmodels.offices;
import java.util.logging.Level;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
public class ExecuteReport {
public static void main(String[] args) {
ExecuteReport er = new ExecuteReport();
try {
er.executeReport();
} catch(Exception ex) {
System.out.println(ex.toString());
}
}
public void executeReport() throws EngineException {
IReportEngine engine = null;
EngineConfig config = null;
IReportEngineFactory factory = null;
Object factoryObj = null;
try {
config = new EngineConfig();
config.setBIRTHome("C:\\birt-runtime-4.6.0-20160607\\ReportEngine");
config.setLogConfig("C:\\temp\\test", Level.FINEST);
Platform.startup(config);
factoryObj = Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
factory = (IReportEngineFactory) factoryObj;
engine = factory.createReportEngine(config);
// Open the report design
IReportRunnable design = null;
String designPath = "C:\\birt-runtime-4.6.0-20160607\\ReportEngine\\samples\\hello_world.rptdesign";
design = engine.openReportDesign(designPath);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
PDFRenderOption PDF_OPTIONS = new PDFRenderOption();
PDF_OPTIONS.setOutputFileName("C:\\temp\\test.pdf");
PDF_OPTIONS.setOutputFormat("pdf");
task.setRenderOption(PDF_OPTIONS);
task.run();
task.close();
engine.destroy();
} catch(final Exception ex) {
ex.printStackTrace();
} finally {
Platform.shutdown();
}
}
}
SETUP:
I installed the BIRT designer using the complete BIRT designer download.
I added all the .jars under the libs folder of the BIRT runtime folder to my build path.
The main method was not part of the example I added it with the intention of getting the report saved to my file system.
The design template I'm referencing is the design example that comes with the BIRT engine.
ISSUES:
When I run the code (Run as -> Java Application) I get the following errors:
A pop up dialog with the message:
Java Virtual Machine Launcher
Error: A JNI error has occured, please check your installation and try again
After I click OK on the message dialog, the console is populated with the following error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/birt/core/framework/PlatformConfig
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException:
org.eclipse.birt.core.framework.PlatformConfig
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 think you are missing following dependency
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.6.0-20160607</version>
</dependency>
Hi guys i've created a saml assertion with opensaml-j and when i run the program an exception occurs and throws NoClassDefFoundError
i've loaded all the necessary jar files but still don't work
here's my code:
package memory;
import java.security.SecureRandom;
import org.joda.time.DateTime;
import org.opensaml.saml.common.SAMLVersion;
import org.opensaml.saml.saml1.core.AttributeStatement;
import org.opensaml.saml.saml1.core.AttributeValue;
import org.opensaml.saml.saml1.core.NameIdentifier;
import org.opensaml.saml.saml1.core.Subject;
import org.opensaml.saml.saml1.core.impl.EvidenceBuilder;
import org.opensaml.saml.saml1.core.impl.NameIdentifierBuilder;
import org.opensaml.saml.saml1.core.impl.SubjectBuilder;
import org.opensaml.saml.saml2.core.Action;
import org.opensaml.saml.saml2.core.Assertion;
import org.opensaml.saml.saml2.core.Attribute;
import org.opensaml.saml.saml2.core.AuthzDecisionStatement;
import org.opensaml.saml.saml2.core.Conditions;
import org.opensaml.saml.saml2.core.DecisionTypeEnumeration;
import org.opensaml.saml.saml2.core.Evidence;
import org.opensaml.saml.saml2.core.Issuer;
import org.opensaml.saml.saml2.core.impl.ActionBuilder;
import org.opensaml.saml.saml2.core.impl.AssertionBuilder;
import org.opensaml.saml.saml2.core.impl.AttributeBuilder;
import org.opensaml.saml.saml2.core.impl.AttributeStatementBuilder;
import org.opensaml.saml.saml2.core.impl.AuthzDecisionStatementBuilder;
import org.opensaml.saml.saml2.core.impl.ConditionsBuilder;
import org.opensaml.saml.saml2.core.impl.IssuerBuilder;
public class CreateSamlAssertion {
#SuppressWarnings("deprecation")
public static Assertion createAssertion(){
Assertion assertion=(Assertion)new AssertionBuilder().buildObject();
assertion.setID(idGenerator());
assertion.setVersion(SAMLVersion.VERSION_20);
assertion.setIssueInstant(new DateTime());
Issuer issuer=(Issuer)new IssuerBuilder().buildObject();
issuer.setNameQualifier("bob");
assertion.setIssuer(issuer);
Subject subject=(Subject)new SubjectBuilder().buildObject();
NameIdentifier nameId=(NameIdentifier)new NameIdentifierBuilder().buildObject();
nameId.setFormat(NameIdentifier.EMAIL);
nameId.setNameIdentifier("alice");
subject.setNameIdentifier(nameId);
Conditions conditions=(Conditions)new ConditionsBuilder().buildObject();
conditions.setNotBefore(new DateTime());
conditions.setNotOnOrAfter(new DateTime().plusMinutes(20));
assertion.setConditions(conditions);
AuthzDecisionStatement authDecisionStatement=getAuthzDecisionStatement();
assertion.getAuthzDecisionStatements().add(authDecisionStatement);
return assertion;
}
private static AuthzDecisionStatement getAuthzDecisionStatement(){
AuthzDecisionStatement aDStatement=(AuthzDecisionStatement)new AuthzDecisionStatementBuilder().buildObject();
DecisionTypeEnumeration decision = DecisionTypeEnumeration.PERMIT;
aDStatement.setDecision(decision);
aDStatement.setResource("http://www.hb.com/Resources/Resource A1");
Action actions=getAction();
actions.setNamespace("http://www.hb.com/Resources/");
aDStatement.getActions().add(actions);
Evidence evidence=getEvidence();
aDStatement.setEvidence(evidence);
return aDStatement;
}
private static Evidence getEvidence(){
Evidence evidence=(Evidence)new EvidenceBuilder().buildObject();
Assertion assertion=(Assertion)new AssertionBuilder().buildObject();
AttributeStatement aStatement=(AttributeStatement) new AttributeStatementBuilder().buildObject();
Attribute attribute1=(Attribute)new AttributeBuilder().buildObject();
attribute1.setName("IssuerCapabilityID");
AttributeValue aValue1=(AttributeValue) AttributeValue.DEFAULT_ELEMENT_NAME;
attribute1.getAttributeValues().add(aValue1);
Attribute attribute2=(Attribute)new AttributeBuilder().buildObject();
attribute2.setName("IssuerCapabilityID");
AttributeValue aValue2=(AttributeValue) AttributeValue.DEFAULT_ELEMENT_NAME;
attribute1.getAttributeValues().add(aValue2);
aStatement.getAttributes().add((org.opensaml.saml.saml1.core.Attribute) attribute1);
aStatement.getAttributes().add((org.opensaml.saml.saml1.core.Attribute) attribute2);
assertion.getAttributeStatements().add((org.opensaml.saml.saml2.core.AttributeStatement) aStatement);
evidence.getAssertions().add(assertion);
return evidence;
}
private static Action getAction(){
Action action=(Action)new ActionBuilder().buildObject();
action.setAction("Read");
action.setAction("Write");
return action;
}
private static String idGenerator(){
SecureRandom random=new SecureRandom();
return String.valueOf(random.nextInt());
}
}
and here's the main class:
package memory;
import org.opensaml.saml.saml2.core.Assertion;
public class SamlTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Assertion assertion=CreateSamlAssertion.createAssertion();
System.out.println(assertion);
}
}
the stack trace
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.opensaml.core.xml.AbstractXMLObject.<init>(AbstractXMLObject.java:47)
at org.opensaml.xmlsec.signature.AbstractSignableXMLObject.<init>(AbstractSignableXMLObject.java:47)
at org.opensaml.saml.common.AbstractSignableSAMLObject.<init>(AbstractSignableSAMLObject.java:44)
at org.opensaml.saml.saml2.core.impl.AssertionImpl.<init>(AssertionImpl.java:83)
at org.opensaml.saml.saml2.core.impl.AssertionBuilder.buildObject(AssertionBuilder.java:45)
at org.opensaml.saml.saml2.core.impl.AssertionBuilder.buildObject(AssertionBuilder.java:40)
at memory.CreateSamlAssertion.createAssertion(CreateSamlAssertion.java:34)
at memory.SamlTest.main(SamlTest.java:9)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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
and thanks in advance
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.
I am new to Neo4j Graph Database and I want to create CyperQueries from java Application . I am using the above neo4j manual
http://docs.neo4j.org/chunked/milestone/query-create.html
I am creating nodes from java APplication as follow
public class CreateQuery
{
public static final String DBPATH="D:/Neo4j/CQL";
public static void main(String args[])
{
GraphDatabaseService path=new EmbeddedGraphDatabase(DBPATH);
Transaction tx=path.beginTx();
try
{
Map<String, Object> props = new HashMap<String, Object>();
props .put( "Firstnamename", "Sharon" );
props .put( "lastname", "Eunis" );
Map<String, Object> params = new HashMap<String, Object>();
params.put( "props", props );
ExecutionEngine engine=new ExecutionEngine(path);
ExecutionResult result=engine.execute( "create ({props})", params );
System.out.println(result);
tx.success();
}
finally
{
tx.finish();
path.shutdown();
}
}
}
I am getting the above error. I am not aware of this errors, please can any 1 help in solving as soon as posible .
Exception in thread "main" java.lang.NoClassDefFoundError: com/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap$Builder
at org.neo4j.cypher.internal.LRUCache.<init>(LRUCache.scala:30)
at org.neo4j.cypher.ExecutionEngine$$anon$1.<init>(ExecutionEngine.scala:84)
at org.neo4j.cypher.ExecutionEngine.<init>(ExecutionEngine.scala:84)
at com.neo4j.CreateQuery.main(CretaeQuery.java:33)
Caused by: java.lang.ClassNotFoundException: com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap$Builder
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)
... 4 more
You may need to add the latest release of this library (ConcurrentLinkedHashMap for Java):
http://concurrentlinkedhashmap.googlecode.com/files/concurrentlinkedhashmap-lru-1.3.1.jar
The code you shared works fine. I think the problem is with your import statements. They should be like this:
import java.util.HashMap;
import java.util.Map;
import org.neo4j.cypher.javacompat.ExecutionEngine;
import org.neo4j.cypher.javacompat.ExecutionResult;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.kernel.EmbeddedGraphDatabase;
It looks like a library error. Perhaps you have imported the wrong version of something?
Just in case, I should point out that you are meant to use the GDB factory for building an embedded instance:
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
Not sure that it will make any difference.