Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 3rd, 2011, 04:21 PM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2006
Location: Webster, NY, .
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?
Reply With Quote
  #2 (permalink)  
Old October 4th, 2011, 04:00 AM
Authorized User
Points: 30, Level: 1
Points: 30, Level: 1 Points: 30, Level: 1 Points: 30, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2011
Location: uk
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.
Reply With Quote
  #3 (permalink)  
Old October 5th, 2011, 11:12 AM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2006
Location: Webster, NY, .
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?
Reply With Quote
  #4 (permalink)  
Old October 5th, 2011, 04:12 PM
Authorized User
Points: 30, Level: 1
Points: 30, Level: 1 Points: 30, Level: 1 Points: 30, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2011
Location: uk
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.