• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Java and its Command Prompt settings  RSS feed

 
Colin Venida
Greenhorn
Posts: 1
Android C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone, Happy Thanksgiving, first of all.

I've been working with the Head First Java book, and I followed the create your first Java program on the website to get the environment and path variables and all sorted out. I can compile and run the program through the command prompt by inputting:

C:\Users\Colin>cd \ConsoleJava\Test

C:\ConsoleJava\Test>javac ImAwesome.java

C:\ConsoleJava\Test>java ImAwesome
//results

That's all fine and dandy, but it gets to be a real pain typing in cd \ConsoleJava\AwesomeFolder to change the directory whenever I want to run or test code.

But when I look in the Head First Java book, the output examples are something like:

%javac AwesomeClass.java
%java AwesomeClass
//results

The book's way seems simpler, and I'd like to set up my computer so it can do the same. So what is "%javac" and "%java" and what do they do? Is the book just skipping over the current directory command or the sake of simplicity, or is it a special way to set up the Environment Variables? :confused:

Thanks for the help :].

~Colin V
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Yes, the book assumes you are already in the proper directory.

javac is the Java compiler
java launches the Java runtime
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

I prefer the way you are running your programs; it is best to create your own directory to keep all your work in. As Bear said, however, the people who wrote HFJ (who have a strong association with this website) may assume you have already got such a directory. The way I often suggest appears here, but you probably won't need the suggestions about CLASSPATH and -cp.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!