File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Cattle Drive and the fly likes how to use com.javaranch.common in the assignment? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "how to use com.javaranch.common in the assignment?" Watch "how to use com.javaranch.common in the assignment?" New topic
Author

how to use com.javaranch.common in the assignment?

Joanne Li
Greenhorn

Joined: Dec 28, 2000
Posts: 6
Dear all.
I downloaded the JavaRanchCommon.zip, and tried to use it in the assignment. I am working on UNIX, and I use "setenv CLASSPATH xxx" to set it to the JavaRanchCommon.zip directory. In my program, "import com.javaranch.common;", but the compiler always complain about this import statement. How to solve it? I tried compile with "javac -classpath xxx myclass.java", the same result. thanks.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Use this instead:
import com.javaranch.common.* ;

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joanne Li
Greenhorn

Joined: Dec 28, 2000
Posts: 6
Thanks Marilyn. I can compile successfully, but got run time error of java.lang.NoClassDefFoundError. Can you pls take a look at my code? Thanks.
import com.javaranch.common.*;

public class DaysOld {

-- code deleted by Marilyn to protect future participants --

}

[This message has been edited by Marilyn deQueiroz (edited January 08, 2001).]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Originally posted by Joanne Li:
Thanks Marilyn. I can compile successfully, but got run time error of java.lang.NoClassDefFoundError. Can you pls take a look at my code? Thanks.

Joanne -
When I ran your code, I did not get this error. Therefore I think that that error is in the classpath setting rather than in your code. When you compile, you use the "path". When you run, you use the "classpath".

You should set your classpath to include the current directory, the directory where your *.java file is, and the directory where you have JavaRanchCommon.zip.

My classpath is
CLASSPATH=C:\Java;C:\Java\JavaRanchCommon.zip;.
because my DaysOld.java file is in C:\Java and my JavaRanchCommon.zip file is also in C:\Java

Joanne Li
Greenhorn

Joined: Dec 28, 2000
Posts: 6
Thanks Marilyn. I can run my program now, and I just submitted to the nitpick. But I have problem doing the next assignment, NaturalLanguageMultiply, just do not know how to start? I do not understand the requirement of Assignment 3.4. Maybe the sample output is better.
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20488
    ∞

Go and book up on what HashMap does. That should help quite a bit.


permaculture Wood Burning Stoves 2.0 - 4-DVD set
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use com.javaranch.common in the assignment?
 
Similar Threads
oop-1 Class path
JavaBeans and class
OOP-1 (DaysOld): setting classpath
catlle drive oop-1 to 4
Problem in Assgnemnt OOP-1 "DaysOld"