Beginner Programming Issue with Javac

I am reading through an introductory book for Java programming and I am facing an issue from the get-go. I am told to run in the terminal javac Example.java. From that command, javac compiler is supposed to create a file called Example.class. All I receive is

javac: file not found: Example.java
Usage: javac <options> <source files>
use -help for a list of possible options

I'm not really sure on how to go further with this. I would appreciate some help. Thank you ahead of time.

3

2 Answers

You should see Example.java if you type the ls (List) command in terminal ?

one@one:~$ ls -l

Your terminal launches by default in your home folder. If your file is in /home/shawn/usr/java, you have to change within terminal to this directory with the cd (ChangeDirectory) command:

one@one:~$ cd /home/shawn/usr/java
one@one:~/shawn/usr/java$

Now type ls -l command again to see your files in /home/shawn/usr/java. To move one level up, e.g. /home/shawn/usr/java back to /home/shawn/usr use two points:

one@one:~/shawn/usr/java$ cd ..
1

while I know this is a linux question, I am also a programmer and I humbly suggest that you download an IDE and work with it on java. Netbeans is pretty good and is my favorite tool for developing java ( on both windows and linux..). Once you download the bundle, the installer will setup a jvm for you to work with from the IDE, thus saving you from a world of hurt when it comes to linux & java.. I assume you would rather spend more time coding and learning the language ( for which netbeans is awesome because it comes with help, auto complete, in code help, a full Visual Basic like editor for Swing which makes for easy GUI buildout drag and drop style) than fighting the system and figure out why java is not in your environment.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like