简体   繁体   English

如何确定eclipse用于启动java程序的命令字符串?

[英]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使用的命令:

  1. Run your application and go to your Debug perspective 运行您的应用程序并转到Debug透视图
  2. In the process viewer, there should be an entry for the app you've just executed 在流程查看器中,应该有刚刚执行的应用程序的条目
  3. Right-click the row that mentions java.exe or javaw.exe 右键单击提及java.exe或javaw.exe的行
  4. Select Properties 选择属性
  5. In the dialog that pops up you'll see the Command Line which includes all classpath entries and arguments 在弹出的对话框中,您将看到包含所有类路径条目和参数的命令行

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.

相关问题 如何从Java启动Eclipse命令? - How can I launch an Eclipse command from Java? 如何在Eclipse中部署Java程序? - How do I deploy a Java program in Eclipse? 如何更改Eclipse IDE的启动JVM? - How do I change my Eclipse IDE's launch JVM? Java:如何在命令行上运行此经过Eclipse编译的程序? - Java: How do I run this eclipse-compiled program on the command line? Java:如何导出使用.txt文件的程序? - Java: How do I export a program which uses a .txt file? 如何从 Java 程序启动完全独立的进程? - How do I launch a completely independent process from a Java program? 如何修改此Java命令行程序以搜索字符串并打印出该字符串出现的次数? - How do I modify this java command line program to search for a string and print out the number occurrences of that string? 我如何在井字游戏计划中确定获胜者 - How do I determine a winner in my Tic Tac Toe program 当它包含一个外部Java程序包时,如何在命令行上编译我的主Java程序? - How do I compile my main Java program on the command line when it includes an external java package? Java:我如何让我的程序确定某个数字是否增加了一定数量,以及是否确定了一个特定的方程式? - Java: How do I have my program determine if a number has went up a certain amount and if so do a particular equation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM