Accepted answer

you can build an eclipse project via a workspace from the command line:

eclipsec.exe -nosplash -data "d:\source\myproject\workspace" -application org.eclipse.jdt.apt.core.aptbuild

it uses the jdt apt plugin to build your workspace automatically. this is also known as a 'headless build'. damn hard to figure out. if you're not using a win32 exe, you can try this:

java -cp startup.jar -nosplash -data "d:\source\myproject\workspace" -application org.eclipse.jdt.apt.core.aptbuild


several years ago eclipse replaced startup.jar with the "equinox launcher"

on eclipse mars (macox):

java -jar /applications/ -nosplash -data "workspace" -application org.eclipse.jdt.apt.core.aptbuild

the -data parameter specifies the location of your workspace.

the version number for the equinox launcher will depend on what version of eclipse you have.


short answer. no. eclipse does not have a command line switch like visual studio to build a project.


hi just addition to vonc comments. i am using ecj compiler to compile my project. it was throwing expcetion that some of the classes are not found. but the project was bulding fine with javac compiler.

so just i added the classes into the classpath(which we have to pass as argument) and now its working fine... :)

kulbir singh


just wanted to add my two cents to this. i tried doing as @kieveli suggested for non win32 (repeated below) but it didn't work for me (on centos with eclipse: luna):

java -cp startup.jar -nosplash -data "d:\source\myproject\workspace" -application org.eclipse.jdt.apt.core.aptbuild

on my particular setup on centos using eclipse (luna) this worked:

$eclipse_home/eclipse -nosplash -application org.eclipse.jdt.apt.core.aptbuild  startup.jar -data ~/workspace

the output should look something like this:

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

not quite sure why it apparently did it twice, but it seems to work.


i wanted to just add this comment to this question for anyone who may encounter this issue in the future.

once, i was working on a project and building complex and inter-related java projects from cmd (using eclipse) was my only option. so, all you need to is this:

  • download your desired eclipse ide (tested it with eclipse oxygen, eclipse ide for enterprise java and web developers and eclipse ide for java developers and it works fine)

  • open your project in the eclipse and change the eclipse configuration based on your project

  • close the eclipse and save the .metadata created from your eclipse (if your workspace is going to be refreshed in the future)

  • run this script in the cmd:

"%eclipse_ide%\eclipsec.exe" -nosplash -data "your_workspace" -application org.eclipse.jdt.apt.core.aptbuild

so, all i wanted to say is that, i could not build using the above commands without the .metadata being in the workspace. make sure it exists there. if you need, make a copy of .metadata and copy-paste it each time your want to execute the commands.


this question contains some useful links on headless builds, but they are mostly geared towards building plugins. i'm not sure how much of it can be applied to pure java projects.


the normal apporoach works the other way around: you create your build based upon maven or ant and then use integrations for your ide of choice so that you are independent from it, which is esp. important when you try to bring new team members up to speed or use a contious integration server for automated builds. i recommend to use maven and let it do the heavy lifting for you. create a pom file and generate the eclipse project via mvn eclipse:eclipse. hth


after 27 years, i too, am uncomfortable developing in an ide. i tried these suggestions (above) - and probably just didn't follow everything right -- so i did a web-search and found what worked for me at ''.

the answer seemed to be a combination of all the answers above (please tell me if i'm wrong and accept my apologies if so).

as mentioned above, eclipse/adt does not create the necessary ant files. in order to compile without eclipse ide (and without creating ant scripts):

1) generate build.xml in your top level directory:

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) next i compile the project. i was a little confused by the request to not use 'ant'. hopefully -- requester meant that he didn't want to write any ant scripts. i say this because the next step is to compile the application using 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) to install the apk onto the device i had to use ant again:

 ant target install

    ** my command line looked like  ant debug install

4) to run the project on my android phone i use adb.

 adb shell 'am start -n'

    ** 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) a side note: to view the log from device use:

 adb logcat

3b) a second side note: the link mentioned above also includes instructions for building the entire project from the command.

hopefully, this will help with the question. i know i was really happy to find anything about this topic here.


to complete andré's answer, an ant solution could be like the one described in emacs, jdee, ant, and the eclipse java compiler, as in:

           line="-warn:+unused -xemacs"/>
        <classpath refid="compile.classpath" />

the compilerarg element also allows you to pass in additional command line args to the eclipse compiler.

you can find a full ant script example here which would be invoked in a command line with:

java -cp c:/eclipse-sdk-3.4-win32/eclipse/plugins/org.eclipse.equinox.launcher_1.0.100.v20080509-1800.jar org.eclipse.core.launcher.main -data "c:\documents and settings\administrator\workspace" -application org.eclipse.ant.core.antrunner -buildfile build.xml -verbose

but all that involves ant, which is not what keith is after.

for a batch compilation, please refer to compiling java code, especially the section "using the batch compiler"

the batch compiler class is located in the jdt core plug-in. the name of the class is org.eclipse.jdt.compiler.batch.batchcompiler. it is packaged into plugins/org.eclipse.jdt.core_3.4.0..jar. since 3.2, it is also available as a separate download. the name of the file is ecj.jar.
since 3.3, this jar also contains the support for jsr199 (compiler api) and the support for jsr269 (annotation processing). in order to use the annotations processing support, a 1.6 vm is required.

running the batch compiler from the command line would give

java -jar org.eclipse.jdt.core_3.4.0<qualifier>.jar -classpath rt.jar


java -jar ecj.jar -classpath rt.jar

all java compilation options are detailed in that section as well.

the difference with the visual studio command line compilation feature is that eclipse does not seem to directly read its .project and .classpath in a command-line argument. you have to report all information contained in the .project and .classpath in various command-line options in order to achieve the very same compilation result.

so, then short answer is: "yes, eclipse kind of does." ;)

Related Query

More Query from same tag