标题: 异常问题 急,谢谢! [打印本页] 作者: 刘宁 时间: 2012-3-23 10:03 标题: 异常问题 急,谢谢! 程序是这样的,我想运行C盘下的酷狗7,javac RunTimeDemo.java没报错然后 java RunTimeDemo异常
class RuntimeDemo
{
public static void main(String[] args)throws Exception
{
Runtime r = Runtime.getRuntime();
r.exec("C:\\Program Files\\KuGou7\\kugou7.exe");
}
}
但是出异常,我在网上查了,他们说可能是classpath设置问题,我看了我的设置的没错,运行例如java SystemDemo都能运行,就这个不行,
Exception in thread "main" java.lang.NoClassDefFoundError: RunTimeDemo (wrong na
me: RuntimeDemo)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
2)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:472) 作者: 张锦萍 时间: 2012-3-23 10:38
你先把那行注释掉,运行一下记事本程序,看有没有问题,再排查
class RuntimeDemo
{
public static void main(String[] args)throws Exception
{
Runtime r = Runtime.getRuntime();
r.exec("notepad.exe");
// r.exec("C:\\Program Files\\KuGou7\\kugou7.exe");
public class RuntimeDemo {
public static void main(String[] args)throws Exception
{
Runtime r = Runtime.getRuntime();
r.exec("C:\\Program Files\\StormII\\Storm.exe");
}