java protobuf run-time formal example not working - java

I am trying to run the official example for protobuf in java source from here,
followed the README.md
protoc generate the javasource code fine but I can not run the code by:
1- java AddPerson data
or
2- java -cp protobuf-java-3.5.1.jar AddPerson
1- Error for java AddPerson data is:
Exception in thread "main" java.lang.NoClassDefFoundError:
"com/google/protobuf/MessageOrBuilder
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 AddPerson.main(AddPerson.java:69)
Caused by: java.lang.ClassNotFoundException:
com.google.protobuf.MessageOrBuilder
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)
... 25 more"
2- Error for: java -cp target/protobuf-java-3.5.1.jar AddPerson
Error: Could not find or load main class AddPerson
[enter image description here][2]

Try including the current directory in the classpath:
java -cp .:target/protobuf-java-3.5.1.jar AddPerson
The .: is to append classpath. For windows, it is ; instead of :.[1]
[1] https://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html

Related

A JNI error has occurred

when i try to run a jar file i get this error
c:\java -cp Elegit-1.1.1-shaded.jar elegit.Main
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)
at sun.security.util.SignatureFileVerifier.process(Unknown Source)
at java.util.jar.JarVerifier.processEntry(Unknown Source)
at java.util.jar.JarVerifier.update(Unknown Source)
at java.util.jar.JarFile.initializeVerifier(Unknown Source)
at java.util.jar.JarFile.getInputStream(Unknown Source)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(Unknown Source)
at sun.misc.Resource.cachedInputStream(Unknown Source)
at sun.misc.Resource.getByteBuffer(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 sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
i work on branch for elegit. and struggle to run it

REST Assured: missing class that's (apparently) not missing

Here's my simple code:
import static com.jayway.restassured.RestAssured.get;
public class testget {
public static void main(String[] args) {
Response countryName = get("http://maps.googleapis.com/maps/api/geocode/json?latlng=45.2542285874,30.2564857&sensor=false");
System.out.println(countryName);
System.exit(0);
}
}
When running, I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/jayway/restassured/mapper/factory/ObjectMapperFactory
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 com.jayway.restassured.config.RestAssuredConfig.<init>(RestAssuredConfig.java:41)
at com.jayway.restassured.RestAssured.<clinit>(RestAssured.java:423)
at testeget.main(testeget.java:6)
Caused by: java.lang.ClassNotFoundException: com.jayway.restassured.mapper.factory.ObjectMapperFactory
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)
... 15 more
But the Rest Assured lib is loaded, otherwise the get method wouldn't even be called... What could it be?
I'm using Rest Assured 2.8.
Update:
I'm using Eclipse to run it, and the classpath has, besides the default Java/Eclipse content, the path to the .jar file of Rest Assured and it's dependencies, as listed on their website.
Dependencies list on the bottom of the page (all added to the classpath).
http://mvnrepository.com/artifact/com.jayway.restassured/rest-assured/2.8.0

driven off the jar file compression

How to run a Sikulix.class ?
This is the error I'm getting.
D:\test_sikuli\sikulix>java -cp D:\test_sikuli\sikulix\org\sikuli\ide SikuliIDE
Exception in thread "main" java.lang.NoClassDefFoundError: SikuliIDE (wrong name: org/sikuli/ide/SikuliIDE)
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 sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
The class you want to run is apparently org.sikuli.ide.SikuliIDE. You need to set the classpath to the top folder and not to the package folder and use the qualified class name.
D:\test_sikuli\sikulix>java -cp D:\test_sikuli\sikulix org.sikuli.ide.SikuliIDE

Exception in thread "main" java.lang.SecurityException: Invalid signature file d igest for Manifest main attributes

I have an application that when run in the IDE (Netbeans 8) works fine. The program makes use of 4 external .jar libraries. It also has a virtual machine argument pointing to a DLL. When I try to execute the .jar from the command line I get an error. This leads me to believe that there is a classpath issue.
This is the error itself:
C:\Users\piuser\Documents\NetBeansProjects\GameTrakaDesktopClient\dist>java -jar
GameTrakaDesktopClient.jar
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for
Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)
at sun.security.util.SignatureFileVerifier.process(Unknown Source)
at java.util.jar.JarVerifier.processEntry(Unknown Source)
at java.util.jar.JarVerifier.update(Unknown Source)
at java.util.jar.JarFile.initializeVerifier(Unknown Source)
at java.util.jar.JarFile.getInputStream(Unknown Source)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(Unknown Source)
at sun.misc.Resource.cachedInputStream(Unknown Source)
at sun.misc.Resource.getByteBuffer(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 gametrakadesktopclient.MainMenuUI.main(MainMenuUI.java:242)
C:\Users\piuser\Documents\NetBeansProjects\GameTrakaDesktopClient\dist>
I have used a workaround to get around this problem because I couldn't figure out a solution. I opened all of the JAR files that my application depends on and removed the META-INF/.DSA and META-INF/.SF files

Getting java.lang.NoClassDefFoundError: org/apache/xerces/dom/ElementNSImpl with Apache ODF Toolkit

I am trying to read an ods file using Apache ODF Toolkit. I am getting java.lang.NoClassDefFoundError error while while trying to load the Spreadsheet using below code-
SpreadsheetDocument data = SpreadsheetDocument.loadDocument(file);
Below is the error trace-
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xerces/dom/ElementNSImpl
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
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$000(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.defineClassCond(Unknown Source)
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$000(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 test.read.ODSFile.ReadODS.main(ReadODS.java:33)
Caused by: java.lang.ClassNotFoundException: org.apache.xerces.dom.ElementNSImpl
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)
... 25 more
Below is the project structure, which shows the classpath-
Is there any dependencies missing?
It seems your code can not find the class:
Caused by: java.lang.ClassNotFoundException: org.apache.xerces.dom.ElementNSImpl
from ODF Toolkit
Note: ODFDOM requires Apache Xerces. The jar file xercesImpl.jar also must exist in a folder lib next to odfxsltrunner.jar file, or it must be in the classpath. The ODF XSLT Runner NetBeans projects includes a reference to xersesImpl.jar in the runtime classpath which has to be adapted after checking out the project.

Categories

Resources