I'm using java with eclipse on windows 7, and I'm trying to build a server program that will run on another (ubuntu) machine on my network.
How can I get eclipse to save the built class files into an external location (I have a drive mapped, or it could even be over ssh/sftp/whatever)?
I have created a git repository on that machine, so the class files are saved in there, however the external libraries that I'm using (which are on the build path) are not being saved as part of the repository. Ideally I would like to have eclipse copy the built classes and libraries used into another directory automatically (and even more ideally get it to run/kill the program automatically when I click on "run", although I suspect that might be being a little too optimistic).
I think ant which I believe is installed with eclipse can do this, but I'm not sure how to make it happen.
You mentioned jar files, and they are actually dependencies. You may want to take a look at some dependency management system like Ivy, or switch to Maven, if you really don't want to include those jar files in your repository.
And alternatively, you are always able to copy the dependencies with Ant's build "scripts" (although they are XMLs, not really "scripts").
It's hard to think of a way to solve "how to save them into an external location". However, you can just write a target, using
<scp>
task (based on ssh) or<ftp>
task, to copy the files after running the standard building.Eclipse has built-in support for Ant. I don't use Eclipse, but I use Netbeans. In Netbeans, a project is actually built with the Ant build file generated by Netbeans. And, you can customize the build file, add your own targets, and then, you can run your own target inside the IDE.
For example, you have a
build
target, adeploy
target, arun
target. The first is generated by Eclipse and you don't need to care about it, while the latter two are written by you. Just write another target, sayall
, and use<antcall>
to run the three targets above one after another. And then, in Eclipse, you can directly runall
target to get all the things handled by Ant.The target machine is a Linux machine, so you can install SSH server easily with apt-get on it. Write two targets in your ant build file, one is
run
, and the other iskill
.Inside the
run
target, you can use<sshexec>
to run your app. The only thing you need to take care is the environment varibles defined on that machine may not be available in ssh session. But that's just a configuration problem. At least you can put the varibles in/etc/environment
, although that's not the best practice.The
kill
target may be a little more complicated. However, in my opinion, if you can write astartup.sh
to start an app, you can always write astop.sh
to close it (take a look at Tomcat's catalina.sh).And also, the
kill
target can be called inside your Eclipse.