tags:

views:

62

answers:

2

I have a java project which contains multiple classes spread out over multiple files.

How do i compile and get this to work ?

Can anyone suggest how to compile this using jCreator (without using a build tool like ant)

A: 

You should just be able to compile each file separately and then run the class with the "main" function ie the one that starts of your program. Its probably a good idea to compile the ones that don't depend on any others first so that when each ones compiled all the classes used in that class are already compiled but I don't know if you need to do this.

David
The Java compiler will look for the referenced classes at compile time, and not necessarily in the same dir as the class you're compiling. (It all depends on the package the classes are in, and the directory structure of the source and class files.)
cHao
ok, i tried what you said and i am getting an error (illegal start of expression) in this line : Thread.sleep(()(1000.0D * Math.random() / this.producerSpeed));
WarDoGG
@WarDoGG: That code doesn't make sense in Java -- you have messed up parentheses. That first empty pair shouldn't be there, or should have something inside.
cHao
@WarDoGG: I think you have forgot to put `long` in the first `()`. Thread.sleep expects a long, and if your expression is not long you need to cast it. `Thread.sleep((long) (expression));`
Patrick
+2  A: 

Without using Ant/Maven etc. (and I would strongly advocate using these - a command line is unmaintainable as your project increases in complexity, and unless you script it you will have to remember how you invoked it last time when you next build) you should be able to pass all your .java files to the compiler on the command line. e.g. in Unix:

javac `find . -name \*.java'

or similar (you will likely need additional args for the classpath etc.)

Brian Agnew
+1 - I also agree with Brian's *strong* recommendation.
Stephen C