aspose file tools*
The moose likes Beginning Java and the fly likes Screwed Install... very basic Q: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Screwed Install... very basic Q:" Watch "Screwed Install... very basic Q:" New topic

Screwed Install... very basic Q:

Krisztian Zsolczai

Joined: Sep 24, 2003
Posts: 3
Hello All,
Since this is my 1st post a little about myself:
I am a Hungarian guy living in FL currently working as security in the afternoons and trying to finish the rest of my flight training during AM when I have $$ for it. My final goal is to become a pilot and finally I am a few months away from instructing. I am 30 and married. I have a BBA and zero coding experience. After getting bored with playing games in the not that busy sec job I decided to dive into Java because I have always wanted to give programming a try, although I am not planning to do it for a living. So you will see me often with questions here. Thanks for any help in advance!
To cut to the point:
I just bought "Learn to Program with Java" by John Smiley
Today after reading some more in this forum I figured out that I needed to set paths to get Java commands to work. So I did that on my desktop and it works like a champ, I finally managed to display "I Love Java!" under DOS :-). But unfortunately yesterday I had no time to do this and started to go after my own head with my laptop. I thought I was still missing some software so I downloaded JVMs.
Apparently I have screwed things by installing both the JVM from Sun and the JVM from MS. Probably this was all included in Netbeans but what did I know.
Now if I try to run the exact copy of the little file (which works fine on my desktop now) on the laptop I get a
"Exception in thread "main" Grades"
message. Btw the same file runs in NetBeans, just not under DOS.
I have winXP Pro on both machines with all the latest updates, and the paths are set correctly now in my laptop as well. Javac command works.
Any help would be appreciated.

Joined: Sep 18, 2003
Posts: 17
u mentioned that it works on desktop.
but does not woks at ur taptop. so possible reasons could be :
java is case sensitive language. ur class name must match to ur file anme and java command.
1.class Grades
} as run programme
java Grades

Wish U Happiness,<br />Sanjeev.
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
It's probably a classpath issue. The classpath directs Java where the class files are to be found. If the ".class" files are in the current directory, then you need to do:
java -cp "." Grades
The reason it works in NetBeans is because NetBeans is managing the classpath for you. In DOS you have to do that yourself.
If you always the use same directory (or directories) for the class files, then you can go into your environment variables and set the CLASSPATH to those directories (separate entries with a semi-colon). Then in DOS you won't have to add the '-cp "."' when you run the files.
Good luck with Java!
Krisztian Zsolczai

Joined: Sep 24, 2003
Posts: 3
with the -cp "." it works on the taptop asd well .... lol taptop g1 though I have an extra kboard for it hehehe
What is funny I was able to set the PATH in enviroments to where the location where the commands are in both computers.
I used this line in both cases:
C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin
It worked for the desktop since I don't have to use anything like -cp there, but it did not for the laptop.
Any further ideas? Do I have the correct line above?
Krisztian Zsolczai

Joined: Sep 24, 2003
Posts: 3
Figured it out!
My problem was that in enviroment for the name I used CLASSPATH on the laptop and only PATH on the desktop. Now everything works just fine.
I just should have used PATH in both cases.
Thanks for the help.
[ September 24, 2003: Message edited by: Krisztian Zsolczai ]
I agree. Here's the link:
subject: Screwed Install... very basic Q: