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:
(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.
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 :)
10-18-2004, 11:14 PM
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
10-18-2004, 11:25 PM
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