Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

toddburch

macrumors 6502a
Dec 4, 2006
748
0
Katy, Texas
The pwd command in Terminal will "print" the "working directory". Or, in other words, display the current working directory.

Todd

(EDIT - in your case above, it will merely show "/", which means the root directory.)
 

chris200x9

macrumors 6502a
Original poster
Jun 3, 2006
906
0
ok thanks a million you guys! sorry for being so noobalicious :eek: One last question do I have to do the java -cp every time?
 

toddburch

macrumors 6502a
Dec 4, 2006
748
0
Katy, Texas
Yes, see #23.

Here's the deal. You can run the javac and java commands from WHEREEVER you want.

If your pwd (your current working directory) is the same as where the files reside, you can let the PATH and -CP default. In other words, there is no need to specify them.

If your pwd is different from where the files reside, you'll need to specify the path/filename.java in the javac command, and specify the CLASS PATH for the java command. As mentioned above, there are different ways to tell Java your CLASSPATH preference. (The environment variable or the -cp switch on the java command itself.)

Now, I typed this REAL slow so it would be clear! LOL

Todd
 

cruzrojas

macrumors member
Mar 26, 2007
67
0
USA
I think Java requires you to make upper case the first letter of all your java programs. I'm not sure if the compiler (javac) will allow you to compile a lowercase named program, or if you will have trouble in the future when you try to inherit classes and so on. So you may want to rename your program to Myfirstapp.java. And make sure you also change the first line of your program as they have to match.

Best Regards
Jesus Cruz

heres my exact terminal output

Last login: Wed Jun 6 14:44:59 on ttyp1
Welcome to Darwin!
chris-chmielewskis-computer:~ chris200x9$ javac /Users/chris200x9/Documents/myfirstapp.java
chris-chmielewskis-computer:~ chris200x9$ java myfirstapp
Exception in thread "main" java.lang.NoClassDefFoundError: myfirstapp
chris-chmielewskis-computer:~ chris200x9$
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I think Java requires you to make upper case the first letter of all your java programs. I'm not sure if the compiler (javac) will allow you to compile a lowercase named program, or if you will have trouble in the future when you try to inherit classes and so on. So you may want to rename your program to Myfirstapp.java. And make sure you also change the first line of your program as they have to match.

Best Regards
Jesus Cruz

JavaCase (as the convention is often called) is just a convention, the compiler does not enforce it. If you were using JavaCase correctly then the main class would be MyFirstApp not Myfirstapp.

The Java naming conventions are set out by Sun.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.