Hello!
This is my first post, and I just learned what UNIX was this week. For a JAVA programming class I am taking, I must be able to create a directory in UNIX, use the nano command to create a JAVA program, compile it, and then run it on the command prompt using the java command.
For some reason I am having trouble, here is what I have tried.
mkdir project13
(I have now created a directory named project13)
cd project13
(I have now changed from default directory to project13 directory)
nano HelloWorld
(This should create a file named HelloWorld that I can edit.)
Here is what I have typed in the nano editor for HelloWorld
public class HelloWorld {
public static void main(String [] args) {
System.out.println("Hello World!");
}
}
I then hit ctrl+x to exit and select NO, I'm not sure what modify buffer means...
then that takes me back to the command prompt.
I then enter javac HelloWorld.java to compile the file but it gives me an error:
cannot find or load main java class
what does this mean?
and what Have I done wrong to this point?
If you have successfully saved your source code and compiled your source you should see two files when you do the ls command in your directory from the command line.
If you still have a problem post the results of ls command here.
I understand the logic of creating a file through the text editor, compiling it, then running it through the command prompt. I am still having problems
when I do the ls command, I can see any listed file.
I even type nano filename in order to see the text of filename in the text editor and it is there
however, when I use these commands
javac filename.java
java filename
The file can not be found, or I get a message saying that the main java class cannot be loaded
My steps:
create a directory: mkdir directoryname
change to directory: cd directoryname
create a file: nano filename
Ctrl+x, NO
compile the file: javac filename.java file cannot be found
java filename: cannot find or load main java class
It helps to read what the computer is telling you. When you hit ctrl-x, nano asks you if you want to save first, and warns you "ANSWERING "No" WILL DESTROY CHANGES". You tell it "no".