• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiling more than 1 .Java File  RSS feed

 
Stephen Black
Ranch Hand
Posts: 52
1
Chrome MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like most greenhorns I have compiled and run my customary "hello world" program and it worked well
Now I have moved on to my second Java program but whats this I can't put it all into one file?
And I simply don't know how to compile a program that is contained in more than 1 .java file despite much googling
Can anybody help me to get my multi file Java program to compile and run?
I have included a link to the files which I am trying to run (I didn't write it it came with the java book that I bought)

http://www.headfirstlabs.com/books/hfjava/chap02.zip
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Steve,
"Compilation and Running " program is certainly beginner's nightmare , but all it takes is few scenarios to master it.

"javac" compiler which comes with JDK is used to compile files. A single file can be compiled with like what you have done.

When it comes to multiple files, say files are in package com/abc/ . Then use
javac *.java
* is wildcard character to compile multiple files

If the files are interlinked ( i mean by import , inheritance) , then just compile the file which at the entry point , others are compiled automatically. Believe me !!

managingfiles
common errors



  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!