• Post Reply Bookmark Topic Watch Topic
  • New Topic

Command Prompt Default End > ?  RSS feed

 
Elliot Thomson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I ran into a little question while going through the first java tutorial - http://www.coderanch.com/how-to/java/how-to-create-java-program

First of all my java is in the folder located at - C:\Users\Moose\Desktop\Java

I managed to do the javac no problem and create a class with the following code:

C:\Users\Moose>javac Desktop\Java\MooseGreetings.java


However, it failed when I tried to do the following ways for classpath

C:\Users\Moose>java -classpath . Desktop\Java\MooseGreetings

C:\Users\Moose>Desktop\Java>java -classpath MooseGreetings


Now I noticed the > symbol right after "Moose" by default in my command prompt ( C:\Users\Moose> ) and after trying around a few things figured I needed to be able to type out the whole path to execute it. I went to test and got the idea to change it directly on the command prompt by going to properties (as that's all I could think of)

C:\Users\Moose\Desktop\Java>

Then tried again:

C:\Users\Moose\Desktop\Java>java -classpath MooseGreetings

And I got the "moooooooo".

I was quite happy to see that I figured out my problem, however, I'm wondering if there's a way to have the default end with a \ so I can manually type in the rest or if I'm doing something really simple wrong?? Or if simply I should have the default and all my files always in the same place.

Thanks for any help!!
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Did you set a system or user CLASSPATH when you set the PATH environment variable? Unless there already is a CLASSPATH set, you should not set one. If the CLASSPATH already exists, add .: to its start.
No, you cannot change the > That is the standard end of the prompt on Windows. On Linux it is $ until you log on as root when it changes to # On OpenSUSE the prompt appears in red if you log on as root.
If you use classpath . and then write Desktop the JVM will look in the Desktop folder inside Java. Which you haven't got.
Try navigating to the Java directory and leaving out the classpath tag and simply write
java MooseGreetings
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot use Java\MooseGreetings not Java.MooseGreetings from the folder one up from the Java folder. Not unless you instructed the class to be in the package called Java. There are restrictions on package names; the compiler will not compile package names starting with java.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!