DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Compiling

  1. #1
    Join Date
    Oct 2004


    Ok, Im following a book called Just Java 2, it shows how to compile a file and then run it with the command prompt by doing like:

    javac clock.java
    java clock

    (the source code for the script you get from their website)

    but i don't have a program that will let me save a file as .java so i saved it as .js and when i do the javac clock.js it just lists a whole bunch of commands to use with javac like -verbose etc and then i do java clock and it says "Exception in thread main: java.lang.NoClassDefFoundError: clock or any other class in the file.

    The code is at: www.afu.com/jj6


  2. #2
    Join Date
    Sep 2004
    what you need to do is simply copy the code from the clock.java file into a new text document on your computer, then rename the text document to exactly the same name as the class, then .java

    so you would
    - copy the contents
    - create a new text file
    - open the text file and paste the java code from the website
    - save and close the text document
    - rename the text file to Clock.java
    - then run your javac command as you were.. "javac Clock.java"
    - then run the clock class like you were.. "java Clock"

    try that
    A kram a day keeps the doctor......guessing

  3. #3
    Join Date
    Oct 2004
    thanks , i got it working, i did try that before but windows wouldnt let me change the type like that only the name so i had to use a command prompt

  4. #4
    Join Date
    Sep 2004
    do you have file extentions showing in windows? if not then it wont let you change them simply by re-typing the extention. It will think that you want to call your file
    Clock.java.txt, to fix this go into (or something similar):

    Tools -> Folder Options -> View and deselect the box saying "hide file extentions for known file types"

    then all of your file types wil be shown, then you can change them easily
    A kram a day keeps the doctor......guessing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.