Java文件可执行,但命令行显示它不是有效的Win32应用程序。

huangapple go评论115阅读模式
英文:

Java file executable, but command line says it's not a valid win32 application

问题

我正在为Google Code Jam练习,其中一些问题要求使用交互式解决方案。我用Java编写了一个解决方案,并在命令提示符中运行了

javac filename.java

当我运行java filename时,文件运行得很完美。然而,当我将该文件与Python脚本结合使用时,我会收到错误消息OSError: [WinError 193] %1不是有效的Win32应用程序

下面的注释文本显示了Google提供的Python脚本在命令行中要求我运行的内容。所以我输入了python interactive_runner.py python testing_tool.py 0 -- ./filename,然后我就收到了win32错误。我是否忘记了做什么事情呢?


<details>
<summary>英文:</summary>

I&#39;m practicing for Google Code Jam, and some of their problems require an interactive solution. I wrote a solution in java and ran 

```javac filename.java``` in the command prompt. When I run ```java filename```, the file runs perfectly. However, when I call this file in combination with python scripts, I get the error message ```OSError: [WinError 193] %1 is not a valid Win32 application```. 

The commented out text below shows what the Google provided python scripts require me to run in command line. So I typed out ```python interactive_runner.py python testing_tool.py 0 -- ./filename```, and that&#39;s when I got the win32 error. Is there something that I&#39;m forgetting to do?

For example:

python interactive_runner.py python testing_tool.py 0 -- ./my_binary

This will run the first test set of a python judge called "testing_tool.py"

that receives the test set number (starting from 0) via command line parameter

with a solution compiled into a binary called "my_binary".


</details>


# 答案1
**得分**: 1

你不能直接运行Java程序 - 它不是一个Win32应用程序。你必须要么:

a) 将Java程序编译成一个jar文件,然后使用 `java -jar 文件名.jar` 运行它,
或者

b) 使用 `java 文件名.java` 运行它。

你需要找到一种方法将这两个命令之一提供给Python脚本。我认为这应该会起作用:
`python interactive_runner.py python testing_tool.py 0 -- java 文件名.java`

<details>
<summary>英文:</summary>

You cannot directly run a Java program - it is not a Win32 application. You have to either

a) Compile the Java program into a jar file, and run it using `java -jar filename.jar`
or

b) Run it using `java filename.java&#39;

You need to find a way of supplying one of those two commands to the Python script. I think this should work: 
`python interactive_runner.py python testing_tool.py 0 -- java filename.java`

</details>



huangapple
  • 本文由 发表于 2020年4月9日 00:25:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/61105403.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定