Badlogic package errors while not using it. In libgdx/java - java

I'm making a a game in java/libgdx. When I run the code in the desktop launcher it gives me a bunch of errors. All the errors comes from the badlogic default package.
My problem is this:
package com.wyvern.paperplane.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.wyvern.paperplane.PaperPlane;
public class DesktopLauncher {
public static void main (String[] args) {
LwjglApplicationConfiguration cfg = new
LwjglApplicationConfiguration();
cfg.title = "my game";
cfg.useGL30 = true;
cfg.width = 720;
cfg.height = 1280;
new LwjglApplication(new PaperPlane(), cfg);
}
}
I don't understand why it gives me all the default badlogic errors while I only use my own package.
Here are some of the errors, note that i don't use any of the com.badlogic:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
at com.badlogic.gdx.graphics.Texture.(Texture.java:92)
at com.badlogic.gdx.graphics.Texture.(Texture.java:88)
at com.wyvern.paperplane.PaperPlane.create(PaperPlane.java:16)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120) Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: badlogic.jpg (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222)
at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:137)

...com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
Check for badlogic.jpg file and usage as mentioned in your error log.
By default there is a code line in main class that libGDX creates (as I see from your code and error log it must be under core/src/com/wyvern/paperplane/PaperPlane.java in line 16)
img = new Texture("badlogic.jpg");
which creates a Texture using badlogic.jpg. And there are 2 badlogic.jpg files located in:
desktop/bin/badlogic.jpg
android/assets/badlogic.jpg
If you deleted them you should remove the code line mentioned above in your main class.

Related

Exception In Initializer Error in Java

I'm trying to execute a protocol through R's console and everytime I get this error:
Error in .jnew("gr.demokritos.iit.radio.home.orchestration.Controller") :
java.lang.ExceptionInInitializerError
I tried to google the error and I only understand that there's something wrong with the static block. Although it seems normal to me.
The two static blocks that exist in the mentioned class:
static ComputationService service;
static {
String conf_path = System.getProperty("config.file", "/root/application.conf");
Config my = ConfigFactory.parseFile(new File(conf_path));
Config config = my.withFallback(ConfigFactory.load());
service = ComputationService$.MODULE$.apply(ActorSystem.apply("benaloh", config));
}
The full source files that are referenced:
ttest.r (jnew at line 55)
controller.java

How can I overcome Error in oracle.odi.core.OdiInstance.createInstance

I am trying my first ODI (Oracle Data Integrator) SDK java program. (below). It just tries to connect.
package docOdi;
import oracle.odi.core.OdiInstance;
import oracle.odi.core.config.MasterRepositoryDbInfo;
import oracle.odi.core.config.OdiInstanceConfig;
import oracle.odi.core.config.PoolingAttributes;
import oracle.odi.core.config.WorkRepositoryDbInfo;
public class Test {
public static void main(String[] args) {
System.out.println("Creating Master and Work Repo objects...");
MasterRepositoryDbInfo masterInfo = new MasterRepositoryDbInfo(
OdiBean.Url, OdiBean.Driver,
OdiBean.Master_User, OdiBean.Master_Pass.toCharArray(),
new PoolingAttributes());
WorkRepositoryDbInfo workInfo = new WorkRepositoryDbInfo(
OdiBean.WorkRepoName, new PoolingAttributes());
System.out.println("Creating Odi Config...");
OdiInstanceConfig odiCfg = new OdiInstanceConfig(masterInfo,workInfo);
System.out.println("Connecting");
OdiInstance odiInstance=OdiInstance.createInstance(odiCfg); // <<< this line error: java.lang.NoClassDefFoundError: org/eclipse/persistence/sessions/Session
}
}
However, I get this error:
java.lang.NoClassDefFoundError: org/eclipse/persistence/sessions/Session
here are the jars I am using
I am not sure why this small/test program is trying to use org/eclipse/persisence/session
I did not see that class in ANY of my odi jars in this folder
C:\Oracle\Middleware\ODI\odi\sdk\lib
I welcome feedback.
so it seems the way to create java programs using the oracle.odi.* packages is to simply add all the jar's in the following folder to your classpath
[your_ODI_HOME]\odi\sdk\lib
As there are many layers of dependencies in the odi java classes
fyi:
Below is a listing of the jars for my v12 ODI install
activation.jar,
aopalliance.jar,
bsf.jar,
bsh-2.0b4.jar,
commons-beanutils-1.7.0.jar,
commons-codec-1.3.jar,
commons-collections-3.2.2.jar,
commons-discovery-0.4.jar,
commons-httpclient-3.1.jar,
commons-io-2.2.jar,
commons-lang-2.2.jar,
commons-logging-1.1.1.jar,
commons-net-3.3.jar,
commons-vfs-1.0.jar,
commons-vfs2-2.0.jar,
connector.jar,
cpld.jar,
enterprise_data_quality.jar,
gson-2.6.2.jar,
hsqldb.jar,
jakarta-oro-2.0.8.jar,
javolution.jar,
jms.jar,
jsch-0.1.53.jar,
json-path-2.2.0.jar,
jython.jar,
jzlib-1.07.jar,
log4j-1.2.16.jar,
odi-core.jar,
odi-sap.jar,
odi-wls-template-gen.jar,
odihapp_common.jar,
odihapp_essbase.jar,
odihapp_planning.jar,
ogg_jmx_interface.jar,
oracle.odi-jaxrsri.jar,
oracle.odi-sdk-jse.jar,
org.eclipse.jgit_3.6.2.201501210735-r.jar,
pop3.jar,
sapjco.jar,
sapjco3.jar,
slf4j-api-1.7.5.jar,
spring-aop.jar,
spring-beans.jar,
spring-context-support.jar,
spring-context.jar,
spring-core.jar,
spring-expression.jar,
spring-instrument-tomcat.jar,
spring-instrument.jar,
spring-jdbc.jar,
spring-jms.jar,
spring-orm.jar,
spring-oxm.jar,
spring-struts.jar,
spring-test.jar,
spring-tx.jar,
spring-web.jar,
spring-webmvc-portlet.jar,
spring-webmvc.jar,
svnkit-1.8.3.jar,
trilead-ssh2-1.0.0-build217.jar,
trove.jar,
woodstox.jar,
XmlSchema-1.4.2.jar,

Why can't java find my class?

I have a class that compiles without error. The class has a main method. But when I try to run it on ubuntu linux from the classes' directory I get a class not found error. I am pretty sure I am missing something dead obvious but I don't see it.
Here is my ls operation:
zookeeper#zookeeper-virtual-machine:~/zookeeper-3.4.5/programs$ ls
CreateGroup.java LsGroup.class LsGroup.java zookeeper-3.4.5.jar
Here is what happens when I to run LsGroup
zookeeper#zookeeper-virtual-machine:~/zookeeper-3.4.5/programs$ java -cp "zookeeper-3.4.5.jar" LsGroup
Exception in thread "main" java.lang.NoClassDefFoundError: LsGroup
Caused by: java.lang.ClassNotFoundException: LsGroup
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: LsGroup. Program will exit.
Here is the code for LsGroup
package org.zookeeper;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.Watcher.Event.KeeperState;
public class LsGroup implements Watcher {
private static final int SESSION_TIMEOUT = 5000;
private ZooKeeper zk;
private CountDownLatch connectedSignal = new CountDownLatch(1);
public void connect(String hosts) throws IOException, InterruptedException {
zk = new ZooKeeper(hosts, SESSION_TIMEOUT, this);
connectedSignal.await();
}
#Override
public void process(WatchedEvent event) { // Watcher interface
if (event.getState() == KeeperState.SyncConnected) {
connectedSignal.countDown();
}
}
public void ls(String groupName) throws KeeperException, InterruptedException {
String path = "/" + groupName;
try {
List<String> children = zk.getChildren(path, false);
for (String child : children) {
System.out.println(path+"/"+child);
System.out.println(zk.getChildren(path +"/"+ child, false));
}
} catch (KeeperException.NoNodeException e) {
System.out.printf("Group %s does not exist\n", groupName);
System.exit(1);
}
}
public void close() throws InterruptedException {
zk.close();
}
public static void main(String[] args) throws Exception {
LsGroup lsGroup = new LsGroup();
lsGroup.connect(args[0]);
lsGroup.ls(args[1]);
lsGroup.close();
}
}
The original problem was that your class was in a package, but you were trying to load it as if it weren't in a package. You'd normally organize your source code to match your package hierarchy, then from the root of the hierarchy, you'd run something like:
java -cp .:zookeeper-3.4.5.jar org.zookeeper.LsGroup
Now that you've temporarily worked around the package issue by moving the code out of a package, the next problem is that the current directory isn't in the classpath. So instead of this:
java -cp "zookeeper-3.4.5.jar" LsGroup
You want:
java -cp .:zookeeper-3.4.5.jar LsGroup
Once you've got that working, you should move the classes back into packages, as per normal Java best practice.
You could remove the package declaration:
package org.zookeeper;
...or just place your LsGroup class in org/zookeeper directory.
The class file is supposed to live in a path like:
org/zookeeper/LsGroup.class
The -cp must include the directory that contains the org/ directory. Then you can
java -cp parent-of-org org.zookeeper.LsGroup
The message "wrong name: org/zookeeper/LsGroup" means, you have to respect the package structure of Java. Use the following directory structure:
./org/zookeeper/LsGroup.class
Then launch java org.zookeeper.LsGroup from within the current directory. The package separator "." will be translated to corresponding directory.
Your files are not under package org.zookeeper
You should be running your class from ~/zookeeper-3.4.5/org/zookeeper
Otherwise JVM won't find the classes to load.
Your class is part of the org.zookeeper package but you keep it in the root folder of your project (/zookeeper-3.4.5/programs).
The qualified name of the package member and the path name to the file are parallel (see Managing Source and Class Files), so if your package is org.zookeeper the class file should be kept in /zookeeper-3.4.5/programs/org/zookeeper
You made two mistakes:
1) You tried to run java LsGroup but you have to use the complete name including packages java org.zookeeper.LsGroup
2) your directory structure is not correct: the package org.zookeeper corresponds with the directory structure ./org/zookeeper/
If you change the directory structure and then run java from the top of this directory structure it should work

Spring Error java.lang.NullPointerException

My Main
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainApp {
public static void main(String[] args) {
System.out.println("hola");
ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
obj.getMessage();
}
}
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory(AbstractRefreshableApplicationContext.java:201)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:127)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:551)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.tutorialspoint.MainApp.main(MainApp.java:9)
Caused by: java.lang.NullPointerException
at org.springframework.beans.factory.support.
DefaultListableBeanFactory.<clinit>(DefaultListableBeanFactory.java:108)
... 7 more
The NullPointerException error is at almost impossible location:
static {
ClassLoader cl = DefaultListableBeanFactory.class.getClassLoader();
try {
javaxInjectProviderClass = cl.loadClass("javax.inject.Provider"); /* line 108 */
} catch (ClassNotFoundException ex) {
// JSR-330 API not available - Provider interface simply not supported then.
}
}
This means that the class is not able to get its own classloader. You must have done something really bad to get this error. Check your JRE/JDK, IDE, ...
UPDATE
There is no explanation other than that you are probably trying to put Spring JARs into JRE's library folder (${java.home}/jre/lib). If that is the case, that is simply wrong. If you really want to include external JARs within JRE, then put them in the official extension directory - ${java.home}/jre/lib/ext.

include PKCS11 library in Java

I have PCKS11 dll and so files for my token.and i want to use [jacknji11][1] library.
my problem is how can i import the dll OR so files to my project.
i use System.loadLibrary("parskey11"); to import my library but i get below Error :
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.pkcs11.jacknji11.jna.JNANative.C_InitToken(Lcom/sun/jna/NativeLong;[BLcom/sun/jna/NativeLong;[B)I
at org.pkcs11.jacknji11.jna.JNANative.C_InitToken(Native Method)
at org.pkcs11.jacknji11.jna.JNA.C_InitToken(JNA.java:119)
at org.pkcs11.jacknji11.C.InitToken(C.java:235)
at org.pkcs11.jacknji11.CE.InitToken(CE.java:272)
at com.mmdt.Main.main(Main.java:13)
i just copy my libparskey11.so file to jni folder in project and use below code :
private static final long INITSLOT = 0;
public static void main(String[] args) {
CE.InitToken(INITSLOT, "pincode".getBytes(), "TEST".getBytes());
long session = CE.OpenSession(INITSLOT, CKS.RW_PUBLIC_SESSION, null,
null);
CE.Login(session, CKU.SO, "pincode".getBytes());
CE.InitPIN(session, "pincode2".getBytes());
CE.Logout(session);
CE.Login(session, CKU.USER, "pincode".getBytes());
byte[] somenewpin = "somenewpin".getBytes();
CE.SetPIN(session, "pincode2".getBytes(), somenewpin);
CE.SetPIN(session, somenewpin, "pincode2".getBytes());
}

Categories

Resources