Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting up JBuilder6 - new to Java

Status
Not open for further replies.
Jan 21, 2002
8
0
0
US
Hi all,

I hope someone can help me...I'm new to Java and I downloaded the JBuilder6 personal edition. I've also created a directory to copy in the source examples from the Deitel book. I created the directory c:\jhtp\com\deitel\ and copied the source in there, because I noticed in the book that it uses packages such as "com.deitel.ch02.*;". If I understand it correctly, the package is just a path to a directory under your working directory, right?
Well, after I copied the examples I was able to go into JBuilder, select add package, and select "com.deitel". Now, I'm able to drill down into the individual chapters, exercises, to the source code.
Then I went into the project properties and tried to setup the paths for the project. I set them up as follows:

Source path: c:/jhtp
Test path: c:/jhtp/test
Output path: C:/jhtp/classes
Working directory: C:/jhtp
Required libraries: <none>

Then I added the main class I wanted to try and run:
com.deitel.ch02.Fig02_01.Welcome1

The classpath is as follows:

SET CLASSPATH= .;C:\jdk1.3\bin;c:\jhtp;c:\jhtp\com

When I tried to run it I got the following error message:
java.lang.NoClassDefFoundError: com/deitel/ch02/Fig02_01/Welcome1

Exception in thread &quot;main&quot;

I sure hope that someone can help me figure out what I'm doing wrong. I want to setup 8 PC's so that a bunch of us can work through the book together. Thank you in advance for any assistance!

Chris
 
Are you running from JBuilder? Did you compile first? Did it compile fine? Did you check C:/jhtp/classes to make sure the class files are being created?

If you are running from the command line then you will also need to put C:/jhtp/classes on the CLASSPATH.
 
Thanks for your quick response. To answer your question, yes, I am running in JBuilder. I have the compile before running checked, but it doesn't appear to be compiling because there is nothing in the classes directory. I read another thread and figured out that I had to add c:\jhtp\classes to the classpath, but that didn't help either.
 
Go ahead do a compile from JBuilder and see what errors it is throwing.
 
By compile, I assume you mean &quot;rebuild&quot;, right? I didn't see an actual &quot;compile&quot; option. Anyway, I did this and got this message:

&quot;Welcome1.java&quot;: Error #: 901 : package . stated in source C:\jhtp\src\com\deitel\ch02\Fig02_01\Welcome1.java does not match directory com.deitel.ch02.Fig02_01

I'm a little confused now, because this source doesn't even reference a package. It's the typical &quot;welcome&quot; program.


public class Welcome1 {
public static void main( String args[] )
{
System.out.println( &quot;Welcome to Java Programming!&quot; );
}
}

The error didn't make any sense, because the paths look the same! Any ideas?

Thanks again!

Chris
 
I did it!!! I got my program to work!!! I'm not exactly sure how or why but it now works!! ;-)

The class I wanted to run was in the package com.deitel.ch02.Fig02_01, but it didn't have a &quot;package&quot; stmt in the source. The class name was &quot;Welcome1&quot;. When I added the line, &quot;package com.deitel.ch02.Fig02_01;&quot; it compiled and ran. So, what I'm assuming is that, since the source did not have the package stmt, it only looked at the source path I had defined in the project, which is c:/jhtp/src&quot;, right? In adding the package stmt to the Welcome1 source, it associated that source with the package (directory path) com.deitel.ch02.Fig02_01 and now could find the source in c:/jhtp/src/com/deitel/ch02/Fig02_01.Welcome1.java. Is this right or am I totally confused?? The later would surprise me!!!! ha ha. Thanks for the help!!!

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top