i use jython-standalone-2.7.2.jar in my application...
compiler is Android Studio 2020 3.1...
minSdk 26 in build.gradle.
An error occurs on the line
PythonInterpreter interp = new PythonInterpreter();
Code:
import org.python.util.PythonInterpreter;
import org.python.core.*;
public class SimpleEmbedded {
public static void main(String []args) throws PyException {
[PythonInterpreter interp = new PythonInterpreter();][1]
/// System.out.println("Hello, world from Java");
// interp.execfile("hello.py");
/// interp.set("a", new PyInteger(42));
// interp.exec("print a");
// interp.exec("x = 2+2");
// PyObject x = interp.get("x");
// System.out.println("x: "+x);
System.out.println("Goodbye ");
}
}
Error:
2021-09-29 21:19:12.368 3202-3202/com.serg.myjython E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.serg.myjython, PID: 3202
**java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/ClassValue**;
at org.python.core.PyType.fromClass(PyType.java:2137)
...
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: **java.lang.ClassNotFoundException: Didn't find class "java.lang.ClassValue"** on path: DexPathList[[zip file "/data/app/~~VsbgLG28nD-Vw7dAU-vIyA==/com.serg.myjython-ODUx9HepPkKuKHI_uTVWdw==/base.apk"],nativeLibraryDirectories=[/data/app/~~VsbgLG28nD-Vw7dAU-vIyA==/com.serg.myjython-ODUx9HepPkKuKHI_uTVWdw==/lib/x86, /system/lib, /system_ext/lib]]
Because the android jdk (built into the phone) does not have the class java.lang.ClassValue. You should copy the class from the open JDK or Oracle JDK, and fix the unable called APIs.
Related
I'm getting NoClassDefFoundError exception when I run this main class through Eclipse
import org.json.simple.parser.JSONParser;
public class A {
public static void main(String args[]) throws IOException {
JSONParser jsonParser = new JSONParser();
// code
}
}
Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/parser/JSONParser
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.JSONParser
I am implementing below dependency in gradle file:
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
Have you changed/set your classpath to your current project? Maybe that's why your program is giving you error
I'm using the Processing library in a simple Java project and I tried to make 3D but I got errors, this is my code :
package fr.ayfri;
import processing.core.PApplet;
import processing.core.PConstants;
public class Main extends PApplet {
public void settings() {
size(1600, 900, PConstants.P3D); // <--- P3D this tells Processing to work with 3D
}
public void draw() {
background(140, 190, 255);
}
public static void main(String[] args) {
String[] processingArgs = { "Main" };
Main main = new Main();
PApplet.runSketch(processingArgs, main);
}
}
But when I run the code I get this error :
java.lang.NoClassDefFoundError: com/jogamp/opengl/GLCapabilitiesImmutable
at processing.opengl.PGraphicsOpenGL.createPGL(PGraphicsOpenGL.java:712)
at processing.opengl.PGraphicsOpenGL.<init>(PGraphicsOpenGL.java:569)
at processing.opengl.PGraphics3D.<init>(PGraphics3D.java:35)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at processing.core.PApplet.makeGraphics(PApplet.java:2266)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2345)
at processing.core.PApplet.initSurface(PApplet.java:10983)
at processing.core.PApplet.runSketch(PApplet.java:10922)
at fr.ayfri.Main.main(Main.java:20)
Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLCapabilitiesImmutable
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 13 more
java.lang.RuntimeException: com/jogamp/opengl/GLCapabilitiesImmutable
at processing.core.PApplet.makeGraphics(PApplet.java:2299)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2345)
at processing.core.PApplet.initSurface(PApplet.java:10983)
at processing.core.PApplet.runSketch(PApplet.java:10922)
at fr.ayfri.Main.main(Main.java:20)
Process finished with exit code 1
So I just don't know how to make this works ?
P3D uses OpenGL behind the scenes and you need to link against the native libraries.
In this case it's the jogl and gluegen-rt libraries present in Processing/Java/core/libraries: simply copy the correct jars for your platform (or all if you want to run the project on multiple platforms) and add them to the build path.
Here's an eclipse OSX example:
The same code is working if I run the class from eclipse as a java application but when I am using same class in android studio I am getting the following RuntimeException.
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/security/sasl/Sasl;
The log :
FATAL EXCEPTION: Thread-62267
Process: com.abcd.abcd, PID: 14825
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/security/sasl/Sasl;
at org.jivesoftware.smack.sasl.SASLMechanism.authenticate(SASLMechanism.java:92)
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:319)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)
at com.abcd.abcd.XmppManager.login(XmppManager.java:99)
at com.abcd.abcd.Main.initializeXmppConnection(Main.java:78)
at com.abcd.abcd.Main.init(Main.java:72)
at com.abcd.abcd.Main.<init>(Main.java:61)
at com.abcd.abcd.MainActivity$1.run(MainActivity.java:32)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.security.sasl.Sasl" on path: DexPathList[[zip file "/data/app/com.abcd.abcd-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at org.jivesoftware.smack.sasl.SASLMechanism.authenticate(SASLMechanism.java:92)
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:319)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:203)
at com.abcd.abcd.XmppManager.login(XmppManager.java:99)
at com.abcd.abcd.Main.initializeXmppConnection(Main.java:78)
at com.abcd.abcd.Main.init(Main.java:72)
at com.abcd.abcd.Main.<init>(Main.java:61)
at com.abcd.abcd.MainActivity$1.run(MainActivity.java:32)
at java.lang.Thread.run(Thread.java:818)
Suppressed: java.lang.ClassNotFoundException: javax.security.sasl.Sasl
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I am stuck here and really not getting what the problem is. Any help guys?
hi if you want to update your library for studio that is one option is good but if you want to use same code in studio as well then you can visit this code here and check if you are doing correct or not.Some problem with ssl permission check here correct way
private XMPPConnection connect() throws XMPPException, SmackException,
IOException {
if ((this.connection != null) && (this.connection.isConnected())) {
return this.connection;
}
ConnectionConfiguration config = new ConnectionConfiguration(HOST1,
5222);
SmackConfiguration.DEBUG_ENABLED = true;
SASLAuthentication.supportSASLMechanism("MD5", 0);
System.setProperty("smack.debugEnabled", "true");
config.setCompressionEnabled(false);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setReconnectionAllowed(true);
config.setSendPresence(true);
config.setRosterLoadedAtLogin(true);
if (Build.VERSION.SDK_INT >= 14) {
config.setKeystoreType("AndroidCAStore");
config.setKeystorePath(null);
} else {
config.setKeystoreType("BKS");
String str = System.getProperty("javax.net.ssl.trustStore");
if (str == null) {
str = System.getProperty("java.home") + File.separator + "etc"
+ File.separator + "security" + File.separator
+ "cacerts.bks";
}
config.setKeystorePath(str);
}
if (connection == null) {
this.connection = new XMPPTCPConnection(config);
}
this.connection.connect();
Roster roster = connection.getRoster();
roster.addRosterListener(new RosterListener() {
#Override
public void presenceChanged(Presence arg0) {
Log.d("deb", "ug");
}
#Override
public void entriesUpdated(Collection<String> arg0) {
Log.d("deb", "ug");
}
#Override
public void entriesDeleted(Collection<String> arg0) {
Log.d("deb", "ug");
}
#Override
public void entriesAdded(Collection<String> arg0) {
Log.d("deb", "ug");
}
});
return this.connection;
}
Thankyou
Hope this will help you.
Android runtime does not have javax.security.sasl package, upgrade your Smack library, there is a custom SASL implementation for android
Probably you should upgrade your library or compile your gradle.
For some informations: What is Gradle in Android Studio?
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.
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.