How to develop without an IDE?

R

Rui Maciel

Is it possible to set up a Java project so that it can be built without
relying on an IDE? If it is, where can I find any information on how to set
up this sort of project?

Bonus points if it's possible to pull this off by writing a single makefile.


Thanks in advance,
Rui Maciel
 
D

David Lamb

Is it possible to set up a Java project so that it can be built without
relying on an IDE? If it is, where can I find any information on how to set
up this sort of project?

Bonus points if it's possible to pull this off by writing a single makefile.

I've always used a combination of Emacs and make. Given your "single
makefile" question, though, I suspect you may have more sophisticated
needs than I do. Care to elaborate?
 
K

Knute Johnson

Is it possible to set up a Java project so that it can be built without
relying on an IDE? If it is, where can I find any information on how to set
up this sort of project?

Bonus points if it's possible to pull this off by writing a single makefile.


Thanks in advance,
Rui Maciel

I use Vim to edit, and a batch file to compile and jar up the classes.
And often a batch file to start them as well.
 
A

Andreas Leitgeb

David Lamb said:
I've always used a combination of Emacs and make. Given your "single
makefile" question, though, I suspect you may have more sophisticated
needs than I do. Care to elaborate?

Not sure if I clarify the OP, or "hijack" his thread, but
suppose you created a working environment in eclipse consisting
of a couple of projects, then what tools are there to create
e.g. an "ant" or "maven"-script from eclipse's own project-
control files, that would allow a headless machine to build
a runnable jar-file with all project-dependencies just like
eclipse does?

Even if the OP didn't mean that, I'd still like to know - so
much for hijacking ;)
 
A

Arne Vajhøj

Is it possible to set up a Java project so that it can be built without
relying on an IDE? If it is, where can I find any information on how to set
up this sort of project?

Bonus points if it's possible to pull this off by writing a single makefile.

Very few rely on their IDE to build for serious projects.

They use tools like Ant or Maven to build with.

You can also write the code without an IDE, but why not utilize
the extra support you get from a Java aware IDE.

Arne
 
L

Lew

Very few rely on their IDE to build for serious projects.

They use tools like Ant or Maven to build with.

You can also write the code without an IDE, but why not utilize
the extra support you get from a Java aware IDE.

OP: Be careful that your problem statement doesn't limit your solution space.

Arne knew that makefiles are not literally the best build mechanism for Java,
so unlike those others who specifically dicussed make with you, he gave you
the idiomatically Java equivalent.

I'm not aware of any prevalence of make in the Java build-and-deployment world.

Ant and Maven are the two most standard mechanisms. Real-life Java
build-and-deployment systems are edifices of scripts (shell, Python, Ruby,
....), continuous-integration (CI) platforms, Ant and/or Maven,
intelligently-crafted logging (of the builds, not just the program runs), and
often much more.

As a solo practitioner you can readily put together a decent ecosystem with
open-source tools, e.g., for Java EE:

git version-control repository
Jenkins continuous-integration framework
Ant build system
bash
Python
Junit unit test framework
EasyMock mock objects for testing code
FindBugs find bugs in source code
Glassfish application server
Geronimo, JBoss
Tomcat, Jetty simpler app server
JSPs, no EJBs, JMX, etc., unless plugins
Apache Web Server HTTP server - all kinds of proxy magic, etc.
EclipseLink, OpenJPA JPA - Java Persistence API)
Postgres RDBMS
Your favorite editor(s) and IDE(s)

You certainly do not need an IDE for any of that, and quite frankly, none of
your build and test stuff should use any IDE files directly, nor should most
editor- or IDE-specific files be in the trunk of your code repository.

With such a suite of tools, I still would add NetBeans or Eclipse (among the
free options) or Aptana (based on Eclipse) as an IDE. While an IDE is not
essential to system development, it is very helpful.

They not only help with code development, they make great dashboards to manage
your libraries, databases, servers, logs, test frameworks, and other tools,
and the interactions amongst them. We programmers tend to monomaniacally focus
only on how IDEs help code production. They are also very handy, particularly
for the solo stages (developer workstation or individual consultant's
production box), to manage the myriad operations matters.

http://git-scm.com/
http://jenkins-ci.org/
http://ant.apache.org/
http://www.ubuntu.com/
http://www.cygwin.com/
http://www.python.org/
http://www.junit.org/
http://www.easymock.org/
http://findbugs.sourceforge.net/
http://glassfish.java.net/
http://geronimo.apache.org/
http://www.jboss.org/
http://tomcat.apache.org/
http://www.eclipse.org/jetty/
http://httpd.apache.org/
http://www.eclipse.org/eclipselink/
http://openjpa.apache.org/
http://www.postgresql.org/
http://www.gnu.org/software/emacs/
http://netbeans.org/
http://eclipse.org/
http://www.aptana.com/
 
M

Martin Gregorie

Is it possible to set up a Java project so that it can be built without
relying on an IDE? If it is, where can I find any information on how to
set up this sort of project?
Simple. Do just as you would for, say, a C project but use Ant instead of
make.
Bonus points if it's possible to pull this off by writing a single
makefile.
Its the norm to use a single build.xml (ant's equivalent of Makefile) to
do everything that make will, i.e. build, clean the source structure,
install the jarfiles. The only significant differences are that its
working with a package hierarchy rather than a set of modules in separate
directories and that it will usually run javadocs too.

This is how I usually work with Java projects, often over an ssh session.
 
A

Arne Vajhøj

OP: Be careful that your problem statement doesn't limit your solution
space.

Arne knew that makefiles are not literally the best build mechanism for
Java, so unlike those others who specifically dicussed make with you, he
gave you the idiomatically Java equivalent.

I'm not aware of any prevalence of make in the Java build-and-deployment
world.

make and Java is like square form and wheels. Not a good mix.

Arne
 
S

Steven Simpson

Is it possible to set up a Java project so that it can be built without
relying on an IDE? If it is, where can I find any information on how to set
up this sort of project?

Bonus points if it's possible to pull this off by writing a single makefile.

Though I use Eclipse for any project of more than a few source files, I
don't use it for building. The projects include the necessary scripts
to be built stand-alone.

I did explore trying to get 'make' to handle per-file dependencies, and
I haven't totally given up yet, but for now I've settled for per-jar
dependencies. I have a pre-packaged 'make' include file, and tell it
that jar foo depends upon the 'API' of jar bar, and it works out rules
that allow compilation of foo to be necessary only if any of foo's
sources have changed (of course), or the API of bar has changed - so bar
can change internally without necessarily triggering recompilation of foo.

Within a jar, nothing special is going on - it's a clean build.

A jar's API is derived from the class files immediately after
compilation. I originally used javap and gawk for this, but javap's
text output is not a consistent format from one vendor to the next, and
the gawk processing is slow, so I eventually wrote a Java program to
parse the class files directly. It's a little faster, and should be
more broadly compatible. However, I think it's still substantially
slower than simply doing clean builds on all jars unconditionally.

Details here:

<http://www.comp.lancs.ac.uk/~ss/software/pkg-jardeps>

Cheers,

Steven
 
B

BGB

make and Java is like square form and wheels. Not a good mix.

it does technically work though, and may make some sense, say, if one is
also building a bunch of C code (say, as part of a JNI wrapper for
native code or similar), or is generally part of a larger project for
which make is already used.
 
A

Arne Vajhøj

it does technically work though, and may make some sense, say, if one is
also building a bunch of C code (say, as part of a JNI wrapper for
native code or similar), or is generally part of a larger project for
which make is already used.

I would rather call ant from make or make from ant to handle those
situations.

Arne
 
N

Nasser M. Abbasi

yes, this works as well.

I guess it is probably whichever is more convenient.

I found that using one good tool for everything is better than
mixing things.

Also, gnumake can do so many more things than just build source
code. I use it to update my html files and pdf files from
Latex sources, and other such things.

As long as the idea that drives the tool is: Perform this action
to update these prerequisites that this target depends on, then better
to use one tool that does this better and for many other things, not
just .java files.

In my tree, I have .f, .f90, .c, .c++, .java, .tex, and many
other files that I want to 'update' in my tree.

Using one tool for all, is better, because one becomes better
at using this one tool, and things are integrated better.
gnumake+bash is pretty much all what I need.

I tried ant, and found that I am doing the same thing I
am already doing in my Makefile, just had to use different
syntax. (I also did not like XML syntax). Also looked at Ruby
script, and few other things. They all pretty much try to do
what Make allready does but using different syntax.

It is very easy to use gnumake to build Java and make jar files and
all. Here is a link showing Makefile for Java from the best book
on gnumake "Managing Projects with GNU make" by Robert Mecklenburg

http://www.makelinux.net/make3/make3-CHP-9#make3-CHP-9

Chapter 9 is all about using make for build Java.

As others said. If you are using an IDE with its own build
system. It is better to have your own makefile to build
your tree, independent of what the IDE has. This way, if
you changed IDE, or move your tree somewhere else where
this IDE is not available, you can still build your tree
any where.

--Nasser
 
N

Nasser M. Abbasi

Nasser M. Abbasi said:
I found that using one good tool for everything is better than
mixing things.
[SNIP]

In my tree, I have .f, .f90, .c, .c++, .java, .tex, and many
other files that I want to 'update' in my tree.

You see no contradiction here?

What contradiction?

I use Makefile to build all the my programs?

Do you mean, why I use different languages? And I should
use one programming language? is that what you mean?

If I can find one programming language that meets all my
programming needs, then I'll use that one language, but
have not found one yet.

--Nasser
 
R

Roedy Green

Is it possible to set up a Java project so that it can be built without
relying on an IDE? If it is, where can I find any information on how to set
up this sort of project?

see http://mindprod.com/jgloss/ant.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..
 
B

BGB

Nasser M. Abbasi said:
I found that using one good tool for everything is better than
mixing things.
[SNIP]

In my tree, I have .f, .f90, .c, .c++, .java, .tex, and many
other files that I want to 'update' in my tree.

You see no contradiction here?

What contradiction?

I use Makefile to build all the my programs?

Do you mean, why I use different languages? And I should
use one programming language? is that what you mean?

If I can find one programming language that meets all my
programming needs, then I'll use that one language, but
have not found one yet.

yeah...

in my case, my project currently uses 5 different programming languages
(to a greater or lesser degree, list does not include makefiles),
several smaller/special purpose DSLs, and an assortment of specialized
file-formats.


I also generally use Make as well...
 
D

Daniel Pitts

Is it possible to set up a Java project so that it can be built without
relying on an IDE? If it is, where can I find any information on how to set
up this sort of project?

Bonus points if it's possible to pull this off by writing a single makefile.


Thanks in advance,
Rui Maciel
for small scale projects, a command line works perfectly well.

I would run commands such as: javac net/virtualinfinity/myproject/Main.java

Once in a while I'd have to do a rm `find . | grep ".class$"` and the
like to do a "clean" build.

Why not use an IDE though? They provide so much!
 
R

Robert Klemme

I found that using one good tool for everything is better than
mixing things.

Which, if followed religiously, will lead you into a situation where it
can get really awkward to do things with tool A which would be extremely
easy with tool B.
Also, gnumake can do so many more things than just build source
code. I use it to update my html files and pdf files from
Latex sources, and other such things.

No wonder because make doesn't do *any* of these things. Make evaluates
timestamps along dependencies (mostly between files) and invokes other
programs that do all the work. GNU make additionally has an extremely
large database of predefined rules, has functions and other capabilities.
As long as the idea that drives the tool is: Perform this action
to update these prerequisites that this target depends on, then better
to use one tool that does this better and for many other things, not
just .java files.

Interestingly GNU make's large built in rule database does not contain
anything related to compiling Java. How do you create your Makefiles in
a way as to invoke javac only for those files which have changed -
especially in light of the fact that one Java source file might create
multiple .class files?
In my tree, I have .f, .f90, .c, .c++, .java, .tex, and many
other files that I want to 'update' in my tree.

Using one tool for all, is better, because one becomes better
at using this one tool, and things are integrated better.
gnumake+bash is pretty much all what I need.

I'm with Leif: if you drink your own cool aid you should be throwing out
all those languages and resort to language [ ] only.
I tried ant, and found that I am doing the same thing I
am already doing in my Makefile, just had to use different
syntax. (I also did not like XML syntax). Also looked at Ruby
script, and few other things. They all pretty much try to do
what Make allready does but using different syntax.

I disagree: ant is very different from make. Ant has built in tasks and
knows itself how to accomplish them. You can even teach it more tasks
via its extension interface. ant rules for building Java projects are
almost certainly a lot simpler than the same for make - as that example
proves.
It is very easy to use gnumake to build Java and make jar files and
all. Here is a link showing Makefile for Java from the best book
on gnumake "Managing Projects with GNU make" by Robert Mecklenburg

http://www.makelinux.net/make3/make3-CHP-9#make3-CHP-9

I did not see the advertized Makefile example but found this gem
(quoting from that page):

"Code declared to be within the a.b.c package would be compiled to class
files in the a/b/c directory. This means that make's normal algorithm
for associating a binary file with its source fails."

Or did you mean this link?
http://www.makelinux.net/make3/make3-CHP-9-SECT-2

I am counting 200+ lines in this Makefile. It inefficiently invokes
javac on all Java sources and defines functions for things that ant can
do out of the box. As a consequence you have to search in different
locations to find out which packages go into which jar file. The same
is probably 15% of the lines as an ant file. Sorry, but that example is
no advertisement for using make to build Java projects.
Chapter 9 is all about using make for build Java.

As others said. If you are using an IDE with its own build
system. It is better to have your own makefile to build
your tree, independent of what the IDE has. This way, if
you changed IDE, or move your tree somewhere else where
this IDE is not available, you can still build your tree
any where.

Modern IDE's usually have integration with ant and / or maven and will
happily generate appropriate build files.

Kind regards

robert
 
R

Rui Maciel

Robert said:
Which, if followed religiously, will lead you into a situation where it
can get really awkward to do things with tool A which would be extremely
easy with tool B.

This isn't necessarily a problem, particularly if a person is already
familiar with tool A while being completely unaware that tool B even
existed.

Then there is a significant issue with being forced to learn an entirely new
tool just because there might be a single thing that it might be able to
handle in a simpler way, and then being forced to deal with a significant
list of things where the new tool fails to perform. Unfortunately, this
appears to be an undistinguishing feature of every automated build system
that has been released.

No wonder because make doesn't do *any* of these things. Make evaluates
timestamps along dependencies (mostly between files) and invokes other
programs that do all the work. GNU make additionally has an extremely
large database of predefined rules, has functions and other capabilities.

There is nothing wrong with this. In fact, I see it as an extremelly
valuable feature. It's a pain in the neck to shoe-horn custom build rules
to an automated build system which was developed with them as an
afterthought.

Interestingly GNU make's large built in rule database does not contain
anything related to compiling Java. How do you create your Makefiles in
a way as to invoke javac only for those files which have changed -
especially in light of the fact that one Java source file might create
multiple .class files?

Maybe build-in rules aren't needed, considering Make's static pattern rules.

http://www.gnu.org/software/make/manual/make.html#Static-Pattern

<snip/>


Rui Maciel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top