Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-17-2004, 11:05 PM   PM User | #1
weronpc
Regular Coder

 
Join Date: Apr 2003
Location: Canada, Ontario, Mississauga
Posts: 312
Thanks: 0
Thanked 0 Times in 0 Posts
weronpc is an unknown quantity at this point
Compile many file.java

My friend downloaded a java source game, my question is, is there a way to compile all .java files at one time?

I normally do this to a single file, javac file.java

what if there is 10 java files?
weronpc is offline   Reply With Quote
Old 04-18-2004, 12:09 AM   PM User | #2
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
If you have all the classes in one file like file.java then all the classes will compile into their respective class files. So for example if you had your Main.java file with this:

PHP Code:

import java
.io.*;

class 
Main{

    public static 
void main(String args[]) throws IOException{

        
String name;
        
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

        
System.out.print("What is this new person's name: ");
        
name stdin.readLine();
        
Person person = new Person(name);

        
System.out.println("A new person was created with the name " person.getName());
    }
}

class 
Person{            
    
    private 
String name;

    public 
Person(String name){
        
this.name name;
    }

    public 
String getName(){
        return 
name;
    }

Now when you compile Main.java you will notice that you end up with two files Main.class and Person.class.
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 04-18-2004, 12:28 AM   PM User | #3
weronpc
Regular Coder

 
Join Date: Apr 2003
Location: Canada, Ontario, Mississauga
Posts: 312
Thanks: 0
Thanked 0 Times in 0 Posts
weronpc is an unknown quantity at this point
NNooo......

I am asking, is there a way to compile more than one .java file?

If I have 10 .java files, how do I compile them without known the order of it? some java file needs the java file to create an object.
weronpc is offline   Reply With Quote
Old 04-18-2004, 12:41 AM   PM User | #4
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
Well you don't have to know the order of the classes. Java handles all that. Ok then download some free java ide that has a feature for creating projects and will allow you to just compile everything in the project then just add all the java files to the project.
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 04-18-2004, 12:46 AM   PM User | #5
weronpc
Regular Coder

 
Join Date: Apr 2003
Location: Canada, Ontario, Mississauga
Posts: 312
Thanks: 0
Thanked 0 Times in 0 Posts
weronpc is an unknown quantity at this point
ok, if I have num1.java and in num1.java has:
public num2 myObject = new num2();

but if I compile num1.java before num2.java, the compiler will say cannot file num2

so I have to compile num2.java, then compile num1.java
weronpc is offline   Reply With Quote
Old 04-18-2004, 01:14 AM   PM User | #6
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
You wouldn't be compiling more than one java file. As I showed in my first post all the classes are in the same java file. Then you compile just that one java file. Java will figure out where everything is at.

Anyways just download some free java ide as I mentioned and do it that way. JCreator is a popular one.

http://www.jcreator.com/download.htm
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 04-18-2004, 08:28 AM   PM User | #7
shmoove
Regular Coder

 
Join Date: Dec 2003
Posts: 367
Thanks: 0
Thanked 0 Times in 0 Posts
shmoove is an unknown quantity at this point
You can just compile them like this:
Code:
javac *.java
The compiler takes care of the dependencies.

shmoove
shmoove is offline   Reply With Quote
Old 04-18-2004, 06:29 PM   PM User | #8
weronpc
Regular Coder

 
Join Date: Apr 2003
Location: Canada, Ontario, Mississauga
Posts: 312
Thanks: 0
Thanked 0 Times in 0 Posts
weronpc is an unknown quantity at this point
javac *.java, that's cool, thanx
weronpc is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:32 PM.


Advertisement
Log in to turn off these ads.