NoClassDefFoundError for aurora.jar - java

I am trying to execute next:
C:\dev\sources\boSchedules\loadJavaLibs>java -cp aurora.jar; ojdbc6.jar
oracle.aurora.server.tools.loadjava.LoadJavaMain -thin -user login/pass#myserv:mysid
%BOS_SRC%/credit/card/api/ScheduleCardApi
And I get next:
Exception in thread "main" java.lang.NoClassDefFoundError: ojdbc6/jar
Caused by: java.lang.ClassNotFoundException: ojdbc6.jar
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)
Could not find the main class: ojdbc6.jar. Program will exit.
Why am I getting this error?

Take a look at the Java Application Launcher man page.
java -cp aurora.jar; ojdbc6.jar
oracle.aurora.server.tools.loadjava.LoadJavaMain -thin -user sched/sched#teach:prod
%BOS_SRC%/credit/card/api/ScheduleCardApi
You have a space between your classpath entries aurora.jar; ojdbc6.jar. The launcher thinks the first jar is the only classpath entry and the ojdbc6.jar is your class containing the main(String[] args) method. It also considers everything after that as arguments to pass to the main(String[] args) method. Remove that space.

Remove the space between the aurora.jar; and the ojdbc6.jar

Spaces delimit the parameters each other. The JVM interprets the command as if you run "ojdbc6.jar" class: "jar" as a classname and "ojdbc6" as a package.
To concat the names of libraries you want to place into classpath for a specific class run please use semicolon with no spaces as "lib1;lib2"
P.S.: Could you please ask your colleagues if you may paste some of our credentials to the SO? :)

Related

NoClassDefFoundError, in the same directory why the program can't find the jar

I write a Java program that read text from excel.So I import some jar like this: poi-3.10-beta2-20130904.jar, poi-ooxml-3.10-beta2-20130904.jar, etc., I can run the program correctly in eclipse.But when I package this program with maven to the directory(C:\workspace2\change\bin),
Then I run this program in command like this :
C:\workspace2\change\bin>java GenerateVar
it occurs this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Cell
at GenerateVar.execute(GenerateVar.java:59)
at GenerateVar.main(GenerateVar.java:25)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Cell
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)
... 2 more
You need to specify classpath with all other jars/classes you use in your program.
E.g. Setting multiple jars in java classpath
When you run it from eclipse in the console there's a command that could be used to run the project, you could copy/paste it from the console to your command line.
In the command java GenerateVar you didn't set -cp option. With this option the command line will look like
java -cp poi-3.10-beta2-20130904.jar poi-ooxml-3.10-beta2-20130904.jar ... GenerateVar
Assumed the libraries are in the current dir.
How to use maven plugins to add dependency to your project and build jar you can find here.
See also this answer if you want to modify manifest.mf manually.
over, I change the way do what I want to do. I use the fat jar which is the eclipse plugin to package the program

Main class not found exception in jar

I am trying to execute the performance-meters.jar according to the tutorial at
http://marklogic.github.io/performance-meters/tutorial.html
using the command
java -cp performance-meters.jar:xcc.jar com.marklogic.performance.PerformanceMeters
I am getting the following error:
D:\MBS\performance-meters-master\performance-meters-master\classes>java -cp performance-meters.jar:xcc.jar com.marklogic.performance.PerformanceMeters
Exception in thread "main" java.lang.NoClassDefFoundError: com/marklogic/performance/PerformanceMeters
Caused by: java.lang.ClassNotFoundException: com.marklogic.performance.PerformanceMeters
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)
Could not find the main class: com.marklogic.performance.PerformanceMeters. Program will exit.
I have kept both the jar files in the same folder.
Links to the jar files are:
http://developer.marklogic.com/code/performance-meters
[http://developer.marklogic.com/products/xcc][3]
Any help would be appreciated.
try to use semicolon instead colon in your cp declaration.
java -cp performance-meters.jar;xcc.jar com.marklogic.performance.PerformanceMeters
You are using windows system or Unix? If windows then I think you need to use ; and not : in separating jars as follows:
java -cp performance-meters.jar ; xcc.jar com.marklogic.performance.PerformanceMeters

TestNG command line not working (java org.testng.TestNG )

i'm trying to run testng tests using command line like this :
C:\Documents and Settings\Administrateur\Bureau\automatic tests testNG>java -cp
C:\Documents and Settings\Administrateur\.m2\repository\org\testng\testng\6.3.1\
testng-6.3.1.jar org.testng.TestNG testng.xml
but i'm getting this error :
Exception in thread "main" java.lang.NoClassDefFoundError: and
Caused by: java.lang.ClassNotFoundException: and
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)
Could not find the main class: and. Program will exit.
So How to add testNG to the classpath.
Thanks
The spaces in the filename are confusing things - Java thinks that only the c:\Documents part is in the classpath argument. Try this:
java -cp
"C:\Documents and Settings"\Administrateur\.m2\repository\org\
testng\testng\6.3.1\testng-6.3.1.jar org.testng.TestNG testng.xml
(where the whole thing is on one line and there's no break after "org" of course)
If you want to run via java on command line, you'll need to either enquote your path ("C:\Documents and Settings\Administrateur\.m2\repository\org\testng\testng\6.3.1\") or alter slightly as follows: C:\Documents%20and%20Settings\Administrateur\.m2\repository\org\testng\testng\6.3.1\. You may also want to run via maven to avoid having to specify this classpath info.

Exception when running java code through command line

I have a simple Class
package chapter10;
public class CompilationTest {
public static void main(String[] args) {
System.out.println("HELLO WORLD");
}
}
The path is
Test\src\chapter10\CompilationTest.java
I successfully compiled the code into the same folder and now I have
Test\src\chapter10\CompilationTest.class
However when I try to run from the same folder it I get this error
>java CompilationTest
Exception in thread "main" java.lang.NoClassDefFoundError: CompilationTest (wrong name: chapter10/CompilationTest)
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)
Could not find the main class: CompilationTest. Program will exit.
When I run using
>java chapter10/PropertiesTest
Exception in thread "main" java.lang.NoClassDefFoundError: chapter10/PropertiesTest
Caused by: java.lang.ClassNotFoundException: chapter10.PropertiesTest
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)
Could not find the main class: chapter10/PropertiesTest. Program will exit.
The class is in the chapter10 package. Run it from the parent directory as:
java chapter10.CompilationTest
The reason for going to the parent is that Java is searching its CLASSPATH, which includes the current directory, for a chapter10 directory containing a CompilationTest.class file. You could also add the src directory's absolute path to the CLASSPATH to achieve the same effect:
set CLASSPATH=C:\...\Test\src
java chapter10.CompilationTest
Or (apparently this is better style) add the -cp or -classpath argument to java:
java -cp "C:\...\Test\src" chapter10.CompilationTest
Run using java chapter10.PropertiesTest. The Java command expects the fully qualified Java class name, not the pathname of the bytecode file.
The Java command locates classes to be loaded by looking on the classpath. This is a list of directories or JAR files to be searched in order. The algorithm used is roughly as follows:
Take the fully qualified name of the class, replace "." characters with the applicable file separator character (e.g. "/" or "\"), and append ".class" to the end. The result is a pathname.
For each entry in the classpath, lookup the pathname relative to the entry.
If the lookup succeeds, load the corresponding file.
Otherwise, continue to the next classpath entry.
If no lookup succeeded, throw a ClassNotFoundException.
The classpath can be set using an explicit command line parameter (-cp <path>) or it can be picked up from a CLASSPATH environment variable. If no classpath is set by either of these methods, a default classpath of "." is assumed, where "." denotes the current directory.
As #BalusC says, best practice is to use the "-cp" argument or create a wrapper script to launch your application. Relying on your shell's $CLASSPATH is a bit flakey, because you never know when it might be overridden or reset.
(This is a simplified description. It does not cover "bootclasspath", classpaths set in loadable JAR files, classloading from URLs, how inner/anonymous classes are handled, etc, etc.)

WSDL2Java Throws Could not find main class: org.apache.axis.wsdl.WSDL2Java

I am trying to create the java files from a remote webservice. I downloaded axis 1.4, copied the lib folder to c:\data\axis\lib which contains of these files:
axis.jar
axis-ant.jar
commons-discovery-0.2.jar
commons-logging-1.0.4.jar
jaxrpc.jar
log4j.properties
log4j-1.2.8.jar
saaj.jar
wsdl4j-1.5.1.jar
I added the c:\data\axis\lib folder to the %AXISCLASSPATH%. Now I am trying to create the java classes using this cmd:
java -cp %AXISCLASSPATH% org.apache.wsdl.WSDL2JAVA http://myurl.com?wsdl
However I keep getting the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/
WSDL2Java
Caused by: java.lang.ClassNotFoundException: org.apache.axis.wsdl.WSDL2Java
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)
Could not find the main class: org.apache.axis.wsdl.WSDL2Java. Program will exit.
Can someone help me to get this working?
Add the jars to the classpath individually if you're using a Java version before 6. If you're using Java 6, see here if you want to use wildcards.
try
java -cp %AXISCLASSPATH% org.apache.wsdl.WSDL2Java http://myurl.com?wsdl
Class names are case sensitive
Login as eucalyptis and compile and it will find all of the jars - this took me forever to figure out!
package structure is wrong. Please use org.apache.axis.wsdl.WSDL2Java

Categories

Resources