[英]How do I determine the command string eclipse uses to launch my java program?
I've got a simple java program, socket, AWT and jUnit dependencies. 我有一个简单的java程序,socket,AWT和jUnit依赖项。
I've built it in eclipse and when I run/debug it from eclipse it works. 我已经在eclipse中构建它,当我从eclipse运行/调试它时,它可以工作。
When I launch it from the command line I get an error saying 当我从命令行启动它时,我得到一个错误说
Exception in thread "main" java.lang.NoClassDefFoundError
I'm guessing it's due to not finding one of the required dependencies in the classpath. 我猜它是由于没有在类路径中找到所需的依赖项之一。
Given that launching from eclipse works, Is there a way of determining what command line eclipse uses to launch the same program? 鉴于从eclipse启动工作,有没有办法确定eclipse用于启动同一程序的命令行?
It looks like your classpath isn't set appropriately when you try to run via the command line. 当您尝试通过命令行运行时,看起来您的类路径未正确设置。 You can easily export the command Eclipse uses by doing this: 您可以通过执行以下操作轻松导出Eclipse使用的命令:
The classpath that Eclipse will use should be visible in your project's properties dialog... Eclipse将使用的类路径应该在项目的属性对话框中可见...
Or, on a Unix-like system, you can cheat, with something like (Linux/Fedora) ps axww | grep java
或者,在类似Unix的系统上,你可以欺骗,例如(Linux / Fedora) ps axww | grep java
ps axww | grep java
to peek around for the actual command-line. ps axww | grep java
来查看实际的命令行。
On Linux, specifically, /proc/
pid /cmdline
will give the entire command-line (split with '\\0' chars, so it may look run-together if you just cat
the file) and /proc/
pid /environ
will show environment variables, if you need to peek at them, as well. 在Linux上,具体来说, /proc/
pid /cmdline
将提供整个命令行(使用'\\ 0'字符拆分,因此如果您只是cat
文件它可能看起来一起运行)和/proc/
pid /environ
将显示环境变量,如果你需要查看它们。 (eg CLASSPATH
environment variable) (例如CLASSPATH
环境变量)
You're asking 2 different questions here. 你在这里问了两个不同的问题。
You can check your Java project's classpath by right clicking on the project name, and left clicking on the Properties option at the bottom. 您可以通过右键单击项目名称来检查Java项目的类路径,然后单击底部的“属性”选项。
On the Properties dialog, left clicking on the Java Build Path brings up the build path dialog. 在Properties对话框中,左键单击Java Build Path,打开构建路径对话框。
If you want to determine the Eclipse command line string, you look at the Run Configurations. 如果要确定Eclipse命令行字符串,请查看“运行配置”。 On the menu, left click on Run, then left click on Run Configurations. 在菜单上,左键单击Run,然后左键单击Run Configurations。 Under Java Application, you should find the run configuration for your project. 在Java Application下,您应该找到项目的运行配置。 The Arguments tab shows you how Eclipse starts your Java project. Arguments选项卡显示Eclipse如何启动Java项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.