Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从命令行构建EclipseJava项目_Java_Eclipse_Command Line - Fatal编程技术网

从命令行构建EclipseJava项目

从命令行构建EclipseJava项目,java,eclipse,command-line,Java,Eclipse,Command Line,有没有办法从命令行编译基于Eclipse的Java项目 我正在尝试自动化我的构建(使用FinalBuilder而不是ant),我既不是Java专家,也不是Eclipse专家。我可能知道如何使用直接的java命令行选项来实现这一点,但是Eclipse项目感觉像是浪费了很多精力 如果无法通过命令行编译Eclipse项目,是否有方法从Eclipse中生成所需的java命令行?或者,是否有一些文件可以供我浏览,以查找它在幕后执行的编译步骤 伙计们,我在寻找一个不包括蚂蚁的答案。让我重复一下原来的问题。

有没有办法从命令行编译基于Eclipse的Java项目

我正在尝试自动化我的构建(使用FinalBuilder而不是ant),我既不是Java专家,也不是Eclipse专家。我可能知道如何使用直接的java命令行选项来实现这一点,但是Eclipse项目感觉像是浪费了很多精力

如果无法通过命令行编译Eclipse项目,是否有方法从Eclipse中生成所需的java命令行?或者,是否有一些文件可以供我浏览,以查找它在幕后执行的编译步骤


伙计们,我在寻找一个不包括蚂蚁的答案。让我重复一下原来的问题。。。。。。。有没有从命令行构建Eclipse项目的方法

我不认为这是一个不合理的问题,因为我可以为visual studio做这样的事情:

devenv.exe /build "Debug|Any CPU" "C:\Projects\MyProject\source\MyProject.sln"

通常的方法是相反的:您基于或创建构建,然后为您选择的IDE使用集成,这样您就可以独立于IDE,尤其是当您尝试让新团队成员加快速度或使用连续集成服务器进行自动化构建时,这一点尤为重要。我建议使用maven,让它为您完成繁重的工作。创建一个pom文件并通过mvnEclipse:eclipse生成eclipse项目。HTH包含一些关于无头构建的有用链接,但它们主要面向构建插件。我不确定其中有多少可以应用于纯Java项目。

为了完成André的回答,ant解决方案可以像中描述的那样,如:


但所有这些都涉及到蚂蚁,这不是基思想要的

有关批编译,请参阅,特别是“使用批编译器一节”

批处理编译器类位于JDT核心插件中。类的名称是org.eclipse.jdt.compiler.batch.BatchCompiler。它被打包到plugins/org.eclipse.jdt.core_3.4.0..jar中。从3.2版开始,它也可以单独下载。文件名为ecj.jar。
从3.3开始,这个jar还包含对jsr199(编译器API)和jsr269(注释处理)的支持。为了使用注释处理支持,需要一个1.6 VM

从命令行运行批处理编译器会

java -jar org.eclipse.jdt.core_3.4.0<qualifier>.jar -classpath rt.jar A.java
该部分还详细介绍了所有java编译选项

与VisualStudio命令行编译功能的区别在于,Eclipse似乎没有直接读取命令行参数中的.project和.classpath。为了获得完全相同的编译结果,您必须在各种命令行选项中报告.project和.classpath中包含的所有信息

所以,简短的回答是:“是的,Eclipse有点像。”;)

简短的回答。不
Eclipse没有像Visual Studio那样的命令行开关来构建项目。

Hi只是添加了VonC注释。我正在使用ecj编译器编译我的项目。有一种解释是,有些类找不到。但是这个项目用javac编译器构建得很好

因此,我刚刚将类添加到类路径中(我们必须将其作为参数传递),现在它工作正常了…:)


Kulbir Singh

您可以从命令行通过工作区构建eclipse项目:

eclipsec.exe -noSplash -data "D:\Source\MyProject\workspace" -application org.eclipse.jdt.apt.core.aptBuild
它使用
jdtapt
插件自动构建您的工作区。这也被称为“无头构建”。很难弄清楚。如果未使用win32 exe,可以尝试以下操作:

java -cp startup.jar -noSplash -data "D:\Source\MyProject\workspace" -application org.eclipse.jdt.apt.core.aptBuild
更新

几年前,eclipse用“equinox启动器”取代了
startup.jar

在月食火星(MacOX)上:

-data
参数指定工作区的位置


equinox启动器的版本号将取决于您拥有的eclipse版本。

27年后,我也不习惯在IDE中开发。我尝试了这些建议(如上所述)——可能只是没有完全按照正确的方法操作——所以我做了一次web搜索,在“”中找到了适合我的方法

答案似乎是以上所有答案的组合(如果我错了,请告诉我,如果是,请接受我的道歉)

如上所述,eclipse/adt不创建必要的ant文件。为了在没有eclipse IDE的情况下编译(并且不创建ant脚本):

1) 在顶级目录中生成build.xml:

android list targets  (to get target id used below)

android update project --target target_id --name project_name  --path top_level_directory

   ** my sample project had a target_id of 1 and a project name of 't1', and 
   I am building from the top level directory of project
   my command line looks like android update project --target 1 --name t1 --path `pwd`
2) 接下来我编译这个项目。我对不使用“ant”的要求有点困惑。 希望——请求者的意思是他不想写任何ant脚本。我这样说 因为下一步是使用ant编译应用程序

 ant target

    this confused me a little bit, because i thought they were talking about the
    android device, but they're not.  It's the mode  (debug/release)
    my command line looks like  ant debug
3) 要将apk安装到设备上,我必须再次使用ant:

 ant target install

    ** my command line looked like  ant debug install
4) 为了在我的android手机上运行该项目,我使用adb

 adb shell 'am start -n your.project.name/.activity'

    ** Again there was some confusion as to what exactly I had to use for project 
    My command line looked like adb shell 'am start -n com.example.t1/.MainActivity'
    I also found that if you type 'adb shell' you get put to a cli shell interface
    where you can do just about anything from there.
3A)旁注:查看设备使用日志:

 adb logcat
3B)第二个旁注:上述链接还包括从命令构建整个项目的说明


希望这将有助于解决这个问题。我知道我真的很高兴在这里找到关于这个话题的任何东西。

我只想在这里加上我的两分钱。我试着按照@Kieveli对非win32的建议去做(下面重复),但对我来说不起作用(在CentOS和Eclipse:Luna上):

在我使用Eclipse(Luna)在CentOS上的特定设置中,这起到了作用:

$ECLIPSE_HOME/eclipse -nosplash -application org.eclipse.jdt.apt.core.aptBuild  startup.jar -data ~/workspace
输出应如下所示:

Building workspace
Building '/RemoteSystemsTempFiles'
Building '/test'
Invoking 'Java Builder' on '/test'.
Cleaning output folder for test
Build done
Building workspace
Building '/RemoteSystemsTempFiles'
Building '/test'
Invoking 'Java Builder' on '/test'.
Preparing to build test
Cleaning output folder for test
Copying resources to the output folder
Analyzing sources
Compiling test/src/com/company/test/tool
Build done

不太清楚为什么它显然做了两次,但它似乎起了作用。

简短回答:是的。Eclipse有点像。除非您必须在各种命令行选项中报告.project和.classpath中包含的所有信息,否则通常会使用ant或maven等外部(到Eclipse)构建解决方案来实现这一点,如其他响应中所述
 adb shell 'am start -n your.project.name/.activity'

    ** Again there was some confusion as to what exactly I had to use for project 
    My command line looked like adb shell 'am start -n com.example.t1/.MainActivity'
    I also found that if you type 'adb shell' you get put to a cli shell interface
    where you can do just about anything from there.
 adb logcat
java -cp startup.jar -noSplash -data "D:\Source\MyProject\workspace" -application org.eclipse.jdt.apt.core.aptBuild
$ECLIPSE_HOME/eclipse -nosplash -application org.eclipse.jdt.apt.core.aptBuild  startup.jar -data ~/workspace
Building workspace
Building '/RemoteSystemsTempFiles'
Building '/test'
Invoking 'Java Builder' on '/test'.
Cleaning output folder for test
Build done
Building workspace
Building '/RemoteSystemsTempFiles'
Building '/test'
Invoking 'Java Builder' on '/test'.
Preparing to build test
Cleaning output folder for test
Copying resources to the output folder
Analyzing sources
Compiling test/src/com/company/test/tool
Build done