从命令提示符编译并运行 Eclipse 项目 [英] Compile and run Eclipse Project from command prompt

查看:21
本文介绍了从命令提示符编译并运行 Eclipse 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从命令提示符编译和运行 Java Eclipse 项目?

How to compile and run Java Eclipse Project from command prompt?

如何从命令行仅使用 java 文件名运行 Java Eclipse 项目.我不想使用 Eclipse 生成的类文件或 jar 文件.

How to run a Java Eclipse project from Command Line with java file name only. I don't want to to use class file or jar files generated by Eclipse.

有可能吗?

即使使用 jar 文件,我发现加载静态文件失败,如 FileNotFoundException,如何解决?

Even with jar file, I found loading of static file was failing, as FileNotFoundException, how to solve that?

我是想这样跑的-

http://www.skylit.com/javamethods/faqs/javaindos.html

javac然后java

推荐答案

我知道一个老问题,但如果你想知道运行基于 Eclipse 的项目(即 Eclipse 使用的项目)的命令提示符

Kind of old question I know, but if you want to know command prompt for running Eclipse-based project (i.e the one that Eclipse uses)

  1. 在 Eclipse 中运行您的项目
  2. 转到调试透视图
  3. (无论如何在我的屏幕上)左上角的窗口应该有一点调试"选项卡.
  4. 右键单击您的项目名称,选择 Properties 在下拉底部
  5. 点击命令行"字段(这就是您可能想要).
  6. 按 [ctrl]+A &[ctrl]+C 选择复制
  7. 将其粘贴到命令行中,或者
  8. (我所做的)在 Windows 中,创建新的 *.bat 文本文件并将其粘贴到那里……现在双击该文件应该会运行您的 Java 项目.
  1. Run your project into Eclipse
  2. Goto Debug perspective
  3. (on my screen anyway) Window in top left corner should have a little 'debug' tab.
  4. Right click on name of your project, select Properties at the bottom of drop-down
  5. Click on the 'Command Line' field (this is what you probably want).
  6. Press [ctrl]+A & [ctrl]+C to select and copy
  7. Either paste this into command line, or
  8. (what I did) in Windows, create new *.bat text file and paste it in there ... now double clicking on that file should run your java proj.

如果你想从 Eclipse 中运行一些东西并且像我一样懒惰,这非常有用.

Pretty useful if you wanna run something out of eclipse and are lazy like me.

顺便说一句,我需要这个来导出一个 uni 作业的项目.当然,他们也希望看到 *.java 文件中的代码,并且上面只使用 Eclipse 动态构建的 *.class 文件.批量编译您的 *.java 文件 &然后运行您需要在从上面的过程中获得的 javaw 行之前组合一个适当的 javac 命令并相应地进行调整 - 请查看 Java 文档.尽管 Eclipse 已经完成了库类路径的大部分艰苦工作(我使用了一些库).

BTW I needed this for exporting project for a uni assignment. Of course, they wanted to see code in *.java files too and above just uses *.class files Eclipse builds on the fly. To make batch compile your *.java files & then run you need to put together an appropriate javac command before the javaw line you got from process above and adjust accordingly - look at Java Docs for this. Eclipse has done most of hard work with library class paths though (I was using a few libs).

这篇关于从命令提示符编译并运行 Eclipse 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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