Results 1 to 6 of 6
  1. #1
    MW130 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    317
    Rep Power
    2

    Default Question about when you use textedit/wordpad/any word processor to compile

    So, I like using barebones software to compile my programs. My question is, when I write, say one class called "asteroid", and the other called "spaceship", how will I make java know that they need to be used together? They will be in the same folder, but do I need to put them in a specific package? Is it ok if I write a constructor in one and then call it in another, so long as they are in the same folder? Someone please advise-- worried & confused :(

  2. #2
    MW130 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    317
    Rep Power
    2

    Default Re: Question about when you use textedit/wordpad/any word processor to compile

    bump

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Question about when you use textedit/wordpad/any word processor to compile

    You use those kinds of programs to edit, not compile. Your other questions require an understanding of classpath: PATH and CLASSPATH (The Java™ Tutorials > Essential Classes > The Platform Environment)

    It's good to know how to use rudimentary tools to edit and compile your code, because you may have to sometime. But in general, they will make you much less productive.
    Get in the habit of using standard Java naming conventions!

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,535
    Blog Entries
    7
    Rep Power
    20

    Default Re: Question about when you use textedit/wordpad/any word processor to compile

    Suppose you make the compiler compile the source code for a class A; while compiling, the compiler noticed a reference of some sort to a class B; what is the compiler to do? It starts searching for a compiled class B.class, but where does it search? It searches the value of the classpath variable. If it finds the compiled version of class B, the compiler is happy and continues its job (compiling A). Suppose it doesn't find class B; it starts searching for the source of class B, named B.java; if it finds it, it compiles it (and produces B.class) and goes back to the previous step. You can also specify where the compiler has to look for sources. An alternative is to pass both source (A.java and B.java) on the command line of the compiler: it compiled both classes. Do a "javac -help" for the details.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    MW130 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    317
    Rep Power
    2

    Default Re: Question about when you use textedit/wordpad/any word processor to compile

    JosAH, that really helped. So, if I have a main class and two other classes, should I compile the two others on terminal before compiling the main class?

  6. #6
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Question about when you use textedit/wordpad/any word processor to compile

    If your classpath is set correctly, the other classes will be found and compiled when you compile your main class.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Problem with textedit/wordpad
    By MW130 in forum New To Java
    Replies: 2
    Last Post: 12-16-2013, 11:52 AM
  2. hELP WITH A PROCESSOR SIMULATION
    By Quan567 in forum New To Java
    Replies: 18
    Last Post: 03-23-2011, 08:32 PM
  3. Create a Processor Simulation
    By Quan567 in forum Advanced Java
    Replies: 2
    Last Post: 03-23-2011, 01:28 AM
  4. Address space with 32-bit processor
    By GlideKensington in forum New To Java
    Replies: 1
    Last Post: 04-06-2009, 07:31 PM
  5. Wordpad help.
    By JavaNewbie0000 in forum New To Java
    Replies: 5
    Last Post: 07-30-2008, 12:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •