Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Workbook class

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Workbook class

    Hi everyone,
    It's great to have found this site as a beginning Java programmer. I am working on a program that uses the Workbook class. This is what I've imported:
    import static java.lang.System.*;
    import java.io.File;
    import java.lang.Object;
    import java.util.*;
    import jxl.*;
    An error comes up saying that jxl does not exist. Any ideas?

    Thanks!


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Workbook class

    When you compile (or run) a Java program you have to tell the javac ( or java) executable where it can find the classes you are using. Generally you don't do anything special with respect to System, File and the like because they are"built in" in some sense. But the jxl package you are using is different because it is not part of the standard Java libraries.

    The bottom line is that you must tell the javac executable where the jxl package resides - most likely a jar file, but that's just a guess: consult the documentation that came with the library you are using.

    The list of locations where classes can be found (directories and jar archives) is known as the classpath but resist the temptation to define a CLASSPATH system variable as this is not very flexible. Instead you specify the classpath when you invoke the compiler. Something like

    javac -cp jxl.jar MyApp

    -cp is saying the compiler should look for unusual classes in the jxl.jar file. But, again, consult the docs for how they reccomend doing things. And recognise that IDEs provide their own mechanism for setting the classpath.

    -----

    Don't import java.lang classes (it's not necessary). And - just personal taste - the static import of System is a bit odd. You can't avoid bloat in Java! Just say System.out if that's what you mean. (And like any code you write, don't use static imports unless you understand them and mean to use them.)

Similar Threads

  1. [SOLVED] Storing instances of a Sub Class in it's Super Class (Which is an array)
    By Hiroto in forum Object Oriented Programming
    Replies: 5
    Last Post: November 6th, 2011, 10:36 AM
  2. Replies: 7
    Last Post: July 21st, 2011, 02:29 PM
  3. Replies: 3
    Last Post: April 13th, 2011, 03:30 PM
  4. Help requested - testing a class with a tester class, no methods allowed.
    By miketeezie in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 21st, 2011, 10:40 PM
  5. Replies: 0
    Last Post: April 11th, 2010, 08:56 AM