Wrox Programmer Forums
|
BOOK: Java Programming 24-Hour Trainer by Yakov Fain
This is the forum to discuss the Wrox book Java Programming 24-Hour Trainer by Yakov Fain; ISBN: 978-0-470-88964-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Java Programming 24-Hour Trainer by Yakov Fain section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2011, 04:21 PM
Authorized User
 
Join Date: Nov 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lesson 1 : Class path

I am looking forward to spending 24 hours with this book getting back in the Java fold. I was trained in Java back in 1999 when version 2 was just coming out, but I never became a full time practitioner. My only experiences since then has been with snippets of Javascript here and there. Alot has changed in 10+ years!

My first obstacle in Lesson 1...after running javac command and creating the class file, I attempt to run java command to actually run the program but I get an error:

"Error: Could not find or laod main class HelloWorld"

Googling this I find that I possibly need to set a CLASSPATH variable as well as a PATH variable. Yakov does not make mention of this on page 6 where he spells out how to set the PATH variable.

If I run "java -cp . HelloWorld" the program will run fine but it seems that I need to take the proper step to set the variable. Can someone expand on this?
 
Old October 4th, 2011, 04:00 AM
Authorized User
 
Join Date: Sep 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Re: lesson 1 Class Path

Hi dthoma128

are you running java HelloWorld in the folder where the HelloWorld.java and HelloWorld.class have been saved. I created a folder of c:\practicaljava\lesson1
cd to that directory and ran java HelloWorld.

I think the "Error: Could not find or load main class HelloWorld" is been return because java can not find Helloworld in the current directory, the option -cp will search the path of directories zip and jar files. This is finding Helloworld somewhere in your directory path.

Hope this helps.
 
Old October 5th, 2011, 11:12 AM
Authorized User
 
Join Date: Nov 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Lesson 1 Class Path

Yes I had them both in a folder on my desktop. Does this mean I have to make an entry for this folder in my CLASSPATH environmental variable similar to the PATH variable entry explained on page 6?
 
Old October 5th, 2011, 04:12 PM
Authorized User
 
Join Date: Sep 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default RE: Lesson 1 Class Path

I never added the location of the folder where HelloWorld.java and HelloWorld.class are save to my CLASSPATH my CLASSPATH variable value in Environment Varibles is as follows.

.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip

and the Path for Java.

;C:\Program Files\Java\jdk1.6.0_23\bin

my OS is vista





Similar Threads
Thread Thread Starter Forum Replies Last Post
Lesson 2 - can not create Class BubNorth BOOK: Java Programming 24-Hour Trainer by Yakov Fain 1 March 4th, 2012 09:44 PM
Error while setting class path sujithmathew Linux 1 August 3rd, 2007 01:02 PM
FileInfo Class Path Problem kwilliams VB.NET 6 April 18th, 2007 11:14 AM
Class path setting pedr0 BOOK: Beginning Java 2 5 July 26th, 2004 03:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.