java 无效文件(坏幻数):Exec 格式错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29139321/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
invalid file (bad magic number): Exec format error
提问by user3712016
I am getting below error when i am trying to set classpath. I am using CentyOS. I am trying to complie a java file in command prompt for that i am setting the classpath. On executing the same java program in Intellij , it runs fine. On executing the same from command prompt it shows error for missing jars so for that i added the classpath to that lib on which the error is seen.
当我尝试设置类路径时,出现以下错误。我正在使用 CentyOS。我正在尝试在命令提示符中编译一个 java 文件,因为我正在设置类路径。在 Intellij 中执行相同的 java 程序时,它运行良好。在从命令提示符执行相同的操作时,它显示缺少 jar 的错误,因此我将类路径添加到看到错误的那个库中。
[root@a admin]# export CLASSPATH=/home/admin/TagAPI/lib/org.json-20120521.jar ;/home/admin/TagAPI/lib/testng-6.8.21.jar
invalid file (bad magic number): Exec format error
Any suggestions will be helpful. I am new in both java and linux, thanks!!
任何建议都会有所帮助。我是 java 和 linux 的新手,谢谢!!
回答by Jens
In unix environment the delimiter for classpath is :
so change it to:
在 unix 环境中,类路径的分隔符:
将其更改为:
export CLASSPATH=/home/admin/TagAPI/lib/org.json-20120521.jar:/home/admin/TagAPI/lib/testng-6.8.21.jar
;
is the command delimiter.
;
是命令分隔符。