While running a scheduler program through command prompt, I am getting the below error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/quartz/ScheduleBu
ilder
Caused by: java.lang.ClassNotFoundException: org.quartz.ScheduleBuilder
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: ScheduleEmail. Program will exit.
Even after adding all the jar files also I am getting the following.
Java command : java - cp .;E:/Jars/*; ScheduleEmail
Can anyone please suggest why I am getting this?
When using a wildcard (on windows platform), you need to surround it with quotes to work correctly:
java -cp ".;E:/Jars/*;" ScheduleEmail
1. http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html
first, make sure if there is a typo, there's no space between "-" and "cp"
second, check if quarts jars are in E:/Jars/
Related
I wrote a Java Client Enterprise Application, and it works very good when i run it from Netbeans.
please notice that there is a query run on start up of the application which send a query to Entitybean.
the problem is when i try to run this JAR Application from windows command line, this error appear to me:
java -jar Apps.jar
Exception in thread "main" java.lang.NoClas
sDefFoundError: javax/persistence/Query
at Apps.Main.main(Main.java:75)
Caused by: java.lang.ClassNotFoundException: javax.persistence.Query
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)
... 1 more
I'm surprised! because it connected successfully between EntityManger and Database, so it used libraries of javax.persistence! .. so Why it don't see the library while trying to send a query?!
So how i solve this problem to run the application by command line any where? not from Netbeans only ?!
Notes:
Windows 8
JDK8
I Set JAVA_HOME and PATH Variables on Windows
Thanks,
I have some jars in the current directory, all needing to be in the class path, so I want to use the wildcards convention for classpath. The command line is:
java.exe -classpath * org.python.util.jython args
However I get this error
Exception in thread "main" java.lang.NoClassDefFoundError: G:/repo/builds/jars/edu_mines_jtk/jar
Caused by: java.lang.ClassNotFoundException: G:.repo.builds.jars.edu_mines_jtk.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: G:/repo/builds/jars/edu_mines_jtk.jar. Program will exit.
If I manually expand the wildcard, with
java.exe -classpath edu_mines_jtk.jar;ij.jar;jython.jar;more-jars org.python.util.jython [args]
Then it works as expected.
What's wrong with my wildcards?
JRE 1.6.25 for Win7 64 bit
I found it, under Windows quotes around the wildcarded classpath are required.
But not required if you specify jars explicitly, explaining why the second command works.
Weird.
I'm running OpenStreetMap's Osmosis in Windows XP to cut a subset of data from a larger set. In various incarnations, the program either hangs or gives me the following error:
C:\Documents and Settings\mmorisy\tools>osmosis.bat --read-xml enableDateParsing
=no file="us_zipcodes.osm" --log-progress interval="10" --bounding-box top=43.22
868195 left=-73.5981635 bottom=41.2283584 right=-69.814204 --write-xml file="mas
s_zipcodes.osm"
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/classwor
lds/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.classworlds.Launcher
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.codehaus.classworlds.Launcher. Program will
exit.
I get the feeling that Java isn't properly installed or configured, but I have installed the most revent SDK from Oracle's website and can't figure out where else I might be going wrong, despite maybe half dozen variations.
The error you're getting implies that Java itself is installed correctly, but it can't find the .class file it's trying to run.
At a guess, osmosis.bat has an incorrect -jar or -cp (or -classpath) argument to the classworlds.jar file in it.
When I run my program from terminal by executing the command java rmiserver.LightBulbServer.class I'm getting NoClassDefFoundError :
Exception in thread "main" java.lang.NoClassDefFoundError: rmiserver/LightBulbSe
rver/class
Caused by: java.lang.ClassNotFoundException: rmiserver.LightBulbServer.class
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.loadClassInternal(Unknown Source)
Could not find the main class: rmiserver.LightBulbServer.class. Program will ex
it.
You are most likely running the application like this:
java rmiserver.LightBulbServer.class
You shouldn't add the .class extension when running your program; use only the name of the class:
java rmiserver.LightBulbServer
You're running the command:
java rmiserver.LightBulbServer.class
when you should be running
java rmiserver.LightBulbServer
You need to set some variables before Java can do anything on a system. This is why some people create batch files to get their Java programs running without modifying system variables.
But this usually happens because you didn't set the CLASSPATH.
For example, here is something that may or may not work:
set JAVA_HOME=C:\jdk1.5.0_06
set PATH=C:\jdk1.5.0_06\bin;C:\Windows;C:\Windows\System32
set CLASSPATH=.
java -jar myprogram.jar
Or try this command:
java -jar myprogram.jar -classpath .
I need to run my RMI server RmiEncodingServer) using the command line,
my class files reside in this folder:
C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerClasses
in package hw2.rmi.server.
The code base reside in this folder:
C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerCodeBase
in package hw2.rmi.server.
I use the command line:
java –classpath C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerClasses\ -Djava.rmi.server.codebase=file:/C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerCodeBase -Djava.security.policy=C:\workspace\distributedhw2\permissions.policy hw2.rmi.server.RmiEncodingServer
but I get a "class not found" exception as follows:
Exception in thread "main" java.lang.NoClassDefFoundError: ûclasspath
Caused by: java.lang.ClassNotFoundException: ûclasspath
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: GÇôclasspath. Program will exit.
where have I gone wrong?
also, if you can provide instructions on how to run the server in eclipse, I added the following as a VM argument, but I get a class not found exception to a class that is in the RmiServerCodeBase:
-Djava.security.policy=C:\workspace\distributedhw2\permissions.policy -Djava.rmi.server.codebase=file:/C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerCodeBase
thanks
I found out that the problem was that I was trying to refer to the .java files in my codebase and not .class files, i suppose that propery name "codebase" is a bit misleading. so if you want to do it in your RMI server you can do it this way:
String codeBasePath = "file:/C:/workspace/distributedhw2/"
+ "AgencyServers/RmiEncodingServer/RmiServerClasses/";
System.setProperty("java.rmi.server.codebase",codeBasePath);
or simply pass the following as VM arguments:
-Djava.security.policy=C:\workspace\distributedhw2\permissions.policy -Djava.rmi.server.codebase=file:/C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerClasses