当您无法在python中执行.bat文件而手动执行时,这是非常令人沮丧的。
我在这里附加我的代码:
directory = 'E:/'
with open(os.path.join(directory, 'output_file.bat'), 'w') as OPATH:
OPATH.writelines(['"""',"\n"'E:',"\n",
'javacCreatingUser.java',"\n",'javaCreatingUser',"\n",'"""'])
os.system("E:/output_file.bat")
以上是我的python代码,它正在创建一个带有2个java命令的bat文件
javac CreatingUser.java
java CreatingUser
我可以手动运行.bat文件,它工作正常,但我的python脚本给我以下错误:
java.lang.NoClassDefFoundError: oracle/iam/identity/exception/ValidationFailedException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: oracle.iam.identity.exception.ValidationFailedException
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)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" '"""' is not recognized as an internal or external command,
operable program or batch file.
问题是,如果我的文件中缺少一些类,那么它也不应该手动执行,但手动执行是可以的。
浮云间
相关分类