Java -jar“ / users / admin / Sample code / sample.jar” -空间问题 [英] Java -jar "/users/admin/Sample code/sample.jar" - Space issue

查看:129
本文介绍了Java -jar“ / users / admin / Sample code / sample.jar” -空间问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过命令窗口中的以下代码使用java触发有效负载安装:

I'm trying to trigger a payload installation using java with the help of this code from the command window:

java -jar / users / admin /示例代码/sample.jar-有效载荷 / users / admin /示例代码/有效载荷 -logfile testing.log -loglevel FINE

但是由于目录'/ users / admin / 示例代码 /sample.jar'中存在空格,因此引发了异常。

But because of the space present in the directory '/users/admin/Sample code/sample.jar', exception is being thrown.

我该如何纠正?

推荐答案

(如果我的理解是正确的,那么这比Java问题更多是外壳插值问题,因此您可能希望修改标签以反映这一点。)

(If my understanding is correct, this is more of a shell interpolation problem than a Java problem, so you might want to modify the tags to reflect this.)

这将非常棘手,因为您需要知道在执行某些命令之前,需要经过多少级的解析此命令行处理器外壳会自行解析。最后,我们希望将所有令牌以我们期望的方式呈现给Java进程。

This is going to be tricky because you need to know how many levels of parsing this command line is going to go through until some command processor shell does it's own parsing. At the end of this whole thing we are hoping to have all the tokens presented to the java process in the manner we expect.

这是普遍的问题。

假设您是直接从Shell运行此程序(我认为这就是命令窗口的意思-我在这里要小心),这取决于该Shell如何解析命令转换为令牌,并将控制权传递给Java进程。例如,在Windows上,必需的和可用的引用与POSIX外壳程序不同,并且表现方式也不同。

Assuming you are running this directly from a shell (I think that's what "command window" means -- I'm trying to be careful here) then it depends on how that shell parses the command into tokens, and passes control to the Java process. For example, on Windows the sort of necessary and available quoting is different, and behaves differently, than POSIX shells.

那么,具体的问题是要保护此空间非常重要。对于在其中运行命令的shell,这样java进程将看到其参数,然后启动的Java程序将以正确的方式看到/ its /参数。

The specific problem, then, is protecting this space as significant for the shell you are running the command in, such that the java process sees its arguments, and then the Java program that launches as a result sees /its/ arguments in the right manner.

您不会提到正在运行哪个shell,或者哪个参数失败(java的参数或所调用的Java程序的参数。因此很难提供具体的帮助。

You don't mention which shell you are running, or which of the arguments is failing (the argument to java, or the argument to the java program that is invoked. So it is hard to hand you specific help.

但是,如果您使用某种POSIX shell,则可以在任何部分的有问题的空格中使用一个(或多个)反斜杠转义符,直到获得结果为止

But, if you are using a POSIX shell of some sort, you could use one (or more) backslash escapes on the offending spaces in either part until you get the results you want. Or use nested strong quotes to suppress interpolation by the shell or java main().

您可能想说一下这是什么程序,以及您如何做运行它,在什么平台,以及您得到的结果是什么。重要的是要知道在此启动过程中的什么地方抛出了错误。

You might want to say what sort of program this is, and how you are running it, and on what platform, and what results you are getting, exactly. It is important to know where in this startup process the error is being thrown.

I看到您可能在某种POSIX shell上,在这种情况下,您应该能够使用单引号或反斜杠转义来保护这些参数中的空格[Java进程或main()]。

I see you are probably on a POSIX shell of some sort, in which case, you should be able to use single-quotes or backslash escaping to protect the spaces in these arguments [either to the Java process or the main()].

鉴于这是POSIX外壳,因此似乎找不到启动文件,或者jarfile缺少此类,或者jar清单文件格式错误。此类是否与jarfile中的拼写完全一样(大小写重要!)存在?请记住,在代码,文件名/ jarfile条目和清单文件中的类定义中,类名称必须完全匹配

Given that this is a POSIX shell, and it appears to be failing to find a startup file, either the jarfile is missing this class or the jar manifest file is malformed. Does this class exist, exactly as spelled (case is significant!) in the jarfile? Remember that a class name must match exactly across the class definition in the code, in the filename/jarfile entry and in the manifest file.

也就是说,JVM似乎可以毫无问题地找到jarfile,但是当它加载jarfile以获取清单信息和启动类时,它找不到它。因此,这似乎是jarfile本身的问题,而不是您的-jar optargs包含空格的事实。

That is, it appears that the JVM is finding the jarfile without a problem, but when it loads the jarfile to get the manifest info and the startup class, it fails to find that. So, this seems to be a problem with the jarfile itself, not that fact that your -jar optargs has a space in it.

这篇关于Java -jar“ / users / admin / Sample code / sample.jar” -空间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆