Rookie trying to make my own package

Reading in a real good book - "Thinking in Java" by Bruce Eckel. Really helping me to understand better a lot of the stuff that I had in my Java course at school.
Got to a section where he's showing how to make your own packages. I'll lift directly:
Consider, for
example, creating an alias for System.out.println(�) to reduce
typing. This can be part of a package called tools:
//P.java
// The P.rint & P.rintln shorthand.
package com.bruceeckel.tools;
public class P {
public static void rint(String s) {
System.out.print(s);
public static void rintln(String s) {
System.out.println(s);
You can use this shorthand to print a
String either with a newline (P.rintln(�)) or without a
newline (P.rint(�)).
So, I cut and pasted right into the text editor I use to practice with, saved and compiled it in a subdirectory off of one of the directories in the CLASSPATH, followed with a little test program:
//ToolTest.java
import com.bruceeckel.tools.*;
public class ToolTest {
public static void main(String[] args) {
P.rintln("Available from now on!");
P.rintln("" + 100); // Force it to be a String
P.rintln("" + 100L);
P.rintln("" + 3.14159);
Here's the result of the compile:
C:\Thinking in Java\com\bruceeckel\tools>javac ToolTest.java
ToolTest.java:3: Package com.bruceeckel.tools not found in import.
import com.bruceeckel.tools.*;
^
1 error
C:\Thinking in Java\com\bruceeckel\tools>
At first I tried doing it on my own, making up my own package name, creating my own little source files, but got the same error. So I cut and pasted directly from the book, thinking surely it would work if I used Eckel's own code. Nope.
Any clue what's going wrong? I've checked the CLASSPATH carefully, it includes
C:\Thinki~1
Thanks
Felecha

Your classpath should include "C:\Thinking in Java", not C:\Thinki~1.
Also, your ToolTest.java should be in some other folder than "C:\Thinking in Java\com\bruceeckel\tools" - javac may act weird when it can find the to-be-imported classes in both the current folder and the classpath.
If ToolTest.java had been in the folder "C:\Thinking in Java" you wouldn't have needed to modify the classpath.

Similar Messages

  • Trying to create my own package

    So basically, I am trying to create my own package in WIndows.
    I have created the directory:
    C:\javaclasses\defnull\array
    and in that directory all I have is:
    intcheck.class
    All the class does is check how large an integer array is. Here is the uncompiled code:
    package defnull.array;
    public class intcheck {
         public static int inarray(int[] numbers){
              int i = 0;
              try {
                   for (i = 0; true; i++)
                        numbers[i] = numbers;
              catch (ArrayIndexOutOfBoundsException e){
                   return i;
    I opened up the cpanel, went to system, Advanced, Environment Variables, and added:
    ;C:\javaclasses
    onto the end of the classpath variable.
    Now, here is where I run into issues:
    Problem a:
    If I import the just the intcheck class, the program works fine:
    import defnull.array.intcheck; //  IMPORTING ONLY THE INTCHECK CLASS.
    public class tester {
         public static void main(String[] args){
    int[] hai = new int[18];
    int x = intcheck.inarray(hai);
    System.out.println(x);
    }and the output is "18".
    But if I try to import the entire folder "array" of classes, like this:
    import defnull.array.*; // IMPORTING ENTIRE FOLDER OF CLASSES
    public class tester {
         public static void main(String[] args){
    int[] hai = new int[18];
    int x = intcheck.inarray(hai);
    System.out.println(x);
    }I get these errors
    .\intcheck.java:3: class tester is public, should be declared in a file named tester.java
    public class tester {
           ^
    tester.java:9: cannot access intcheck
    bad class file: .\intcheck.java
    file does not contain class intcheck
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    int x = intcheck.inarray(hai);
            ^
    2 errorsIt should just be importing the whole folder of classes, correct?
    I have even tried to create a new object for it:
    intcheck check = new intcheck();It just gives similar errors

    I dont understand why:
    import defnull.array.intcheck;
    would work but not:
    import defnull.array.*;
    It seems to be that specific class that is not working. i made another simple one to print out a string, which allowed me to use the wildcard.
    what is wrong with that class?

  • HT3819 For home sharing do you have to use one apple ID? Im trying to make my own new account for all my devices (iphone, ipad, mac) , but i still want the music from my dads account.

    For home sharing do you have to use one apple ID? Im trying to make my own new account for all my devices (iphone, ipad, mac) , but i still want the music from my dads account.

    For home sharing do you have to use one apple ID? Im trying to make my own new account for all my devices (iphone, ipad, mac) , but i still want the music from my dads account.

  • OK, now I tried to make my own spry photo album

    but when I tried to name my own images and substitute their
    names in the xml code in the following manner:
    <photo
    path = "travel_01.jpg" //changed to "buildings_01.jpg"
    width = "263"
    height = "350"
    thumbpath = "travel_01.jpg"
    thumbwidth = "56"
    thumbheight = "75">
    </photo>
    <photo
    path = "travel_02.jpg" //changed to "buildings_02.jpg"
    width = "350"
    height = "263"
    thumbpath = "travel_02.jpg"
    thumbwidth = "75"
    thumbheight = "56">
    </photo>
    the photo album didn't work... does anyone know why?
    thank you for your help in advance
    Betsy w.

    The other important thing is that the <img src path
    matches your folder structure.
    In our gallery samples, we are dynamically generating the img
    path with data references. I would start by hardcoding an image
    path that works, so you know your path is correct. Then replace the
    image name with the data reference.
    <img src="mypath/totheimage/travel_01.jpg">
    When that works, then change to:
    <img src="mypath/totheimage/{@path}">
    Let me know if that helps.
    Don

  • Trying to make my own java library need help!

    I have been trying to make a java library that will save data in cdf format.
    Every time I try to implement code using this library i created i get the error shown below, I put the jar file in the jdk/jre/lib/ext file, so when I import it, it does work. But i dont know know what to do with this error any insight would be greatly appreciated,
    Constructor
    You are connected to the OSACBM sever...
    new.xml has been recieved and unmarshalled
    ELEMENT: DAInt:
    DAInt value: 34
    DAInt id: 2000
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no cdfNativeLibrary in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at gsfc.nssdc.cdf.CDFNativeLibrary.<clinit>(CDFNativeLibrary.java:47)
    at gsfc.nssdc.cdf.CDF.create(CDF.java:221)
    at osacbm_client_.CDFHandler.InitializeCDF_File(CDFHandler.java:45)
    at osacbm_client_._Client.Unmarshaller(_Client.java:64)
    at osacbm_client_._Client.<init>(_Client.java:25)
    at osacbm_client_.Main.main(Main.java:19)
    Java Result: 1

    OK, I checked the javadoc myself, and although the text is clear and correct I acknowledge it doesn't help you a lot to investigate the problem, so I'll try to give out a clue:
    -> your problem is that the JVM does find your jar, but doesn't file the native library it depends on (+"cdfNativeLibrary"+).
    You should locate the shared library file (+cdfNativeLibrary.dll+ or cdfNativeLibrary.so depending on your OS), and make sure your PATH variable contains its folder, or add this folder to the java.library.path system property (specified as -D java.library.path=<path/to/folder/containing/libfile> in the launching command line).
    Note that it's not clear from your message if you're writing the gsfc library or a client of it:
    - It the former, and if you're new to Java, then be aware that integrating a native library is not the easiest way to learn Java; just in case, make sure you read and understand a JNI tutorial (for Java Native Interface; I was willing to push you a link, but I realize the [Java tutorial|http://java.sun.com/docs/books/tutorial/] has no such chapter, which reinforces that it is an advanced topic).
    - If the latter, then how to install the library's components should be documented in its manual.

  • Still trying to make my own Tags

    Here's what I've done:
    1. Taken one of my own pictures and resized it in editor down to 20x20 (same size as tags)
    2. Saved it in C:\Pragram files\photoshop elements 3\shared_assets\caticons with the name C_GreetingCards_N.png.
    The saved name matches the way Adobe names their caticons.
    3. I can see it in the directory tree under caticons but it doesn't show up in the palette in Organizer.
    I'm so close. Anyone got the answer to what I'm not doing?
    Thanks in advance.

    Jack....
    I just tried it again on my PC and it works fine....
    1. Start the Editor and open one of the Cat Icon Images.
    2. Delete all the contents and add your own or just modify whats there already. (or just create a new 20x20 pixel image)
    3. Save As with a new name and keeping the PNG file format.
    4. Close the image in the Editor and Open the Organiser.
    5. Go to the Tags Palette and click on the drop down arrow on the New Tag tab.
    6. Select the New Category option
    7. In the pop up window move the slider along underneath Category Icon until you see your own. Click to select it.
    Colin

  • How to make use of package "com.sapportals.wcm.repository"

    Dear all,
    I am trying to make use the package "com.sapportals.wcm.repository" in my SDK development. But when I entered "import com.sapportals.wcm.repository.*;" in my class, a error given out "The import com.sapportals.wcm cannot be resolved.". What should I do?
    Thanks
    Sam

    Hi Armin,
    Sorry that I still got problem on importing and make use of the class for knowledgemanagement. I can found the cooresponding .jar file in folder "jakarta-tomcat-3.3.2\webapps\irj\WEB-INF\plugins\portal\services\knowledgemanagement\lib". And added the services reference as "ServicesReference=htmlb, knowledgemanagement". However, I still can't use the class for KM.
    I have read those code sample from KM in SDN, but they are mentioning the programming part and not the setting. Can you suggest the detail steps and code on adding the KM class into my customize class?
    I am using Eclipse as my development tools.
    Thanks & Regards
    Sam
    Message was edited by: Sam Choy

  • Wana build my own package - how to do that?

    hey,
    i download the Firefox 3 Beta 3 from Mozilla server http://www.mozilla.com/en-US/products/d … lang=en-US
    my question is how can i install it? i need to create PKGBUILD file?
    what should i know more?
    thanks.

    To learn how to make your own packages read the wiki:
    http://wiki.archlinux.org/index.php/Makepkg
    http://wiki.archlinux.org/index.php/ABS
    http://wiki.archlinux.org/index.php/PKGBUILD
    For FF3, libgnome is an optional dependancy (I think).  FF3 attempts to look native on all platform and Gnome was chosen for linux. FF2 already used GTK.
    Last edited by Allan (2008-03-02 22:28:12)

  • I'm trying to make a Bug Database

    Hi there,
    I am trying to make my own bug database app using Objective-C(I will try and work out the Core Data part later - sticking to the code now).
    So here goes.
    I have created the code to add a column;
    NSTableColumn *newColumn = [[NSTableColumn alloc] initWithIdentifier:@"identifier"];
    [[newColumn headerCell] setStringValue:@"column name"];
    [tableView addTableColumn:newColumn];
    That works. But I have two questions;
    1. How do I clear the table of all columns on startup?
    2. How do I add contents to the table! I don't have a data source, I just want to add things when in the application.
    Cheers,
    Ricky.
    P.S - I can't understand why there is a formatting issue in that code.

    The tutorial is based on having a list of "VersionReleases"... and each VersionRelease can potentially have many CommitMessages... so the interface has the two table views. One table view shows you the list of all the VersionReleases and then when you've selected one of the VersionReleases the second table view shows you a list of all the CommitMessages associated with the selected VersionRelease. In addition, each CommitMessage has several pieces of data associated with it (the message, creationDate, and isCommitted attributes). And when you select one of the "CommitMessages" from the second table view then it's data items display in the remaining fields.
    But based on your screen shot it appears that you want to create a list of Bugs to track... each individual bug item will have one notes field, one date founded and one platform (and also one bug name). But there doesn't appear to be a list of several items associated with each bug (like in the tutorial where there's a list of CommitMessages associated with each VersionRelease). So there doesn't appear to be any reason to split the information related to a single bug report into two different entities.
    So (assuming I'm understanding your screen shot correctly) in essence you don't need the "VersionRelease" entity. Your interface looks like it could be handled with one entity similar to the "CommitMessage" entity from the tutorial. Sort of like you removed the "VersionMessage' table view from the left side of the tutorial window and then moved the "CommitMessage" table view from the top right of the window and instead placed it along the left side of the window where the first table view used to be... that gives you essentially what your screen shot displays and eliminates the need for the two entities.
    Your "BugEntry" entity could contain a name, notes, date and platform. The table view on the left of your window would display a list of all the bug names (like the "CommitMessage" table view displays a list of commit messages in the tutorial), then depending on which one was selected the remaining fields would display the notes, date and platform of the selected bug.
    Steve

  • How do i deactivate a device through icloud if the device is broken and i am unable to turn on find my iphone? Also i do not own a apple id as ive been using a family members due to problems when trying to make one?

    How do i deactivate a device through icloud if the device is broken and i am unable to turn on find my iphone? Also i do not own a apple id as ive been using a family members due to problems when trying to make one?

    Hey tyjox,
    Thanks for the question. After reviewing your post, it sounds like you need to deactivate Find My iPhone on a device that does not work. You will need to work with the family member of the account the iPhone is registered with. I would recommend that you use this article to help you resolve or isolate the issue.
    iCloud: Remove your device from Find My iPhone
    http://support.apple.com/kb/PH2702
    Remove an iOS device you no longer have
    If you no longer have the iOS device because you gave it away or sold it, you need to remotely erase it before you can remove it.
    Sign in to icloud.com/#find with your Apple ID (the one you use with iCloud).If you’re using another iCloud app, click the app’s name at the top of the iCloud.com window, then click Find My iPhone.
    Click All Devices, then select the device.
    Click Erase [device], then enter your Apple ID password. Because the device isn’t lost, don’t enter a phone number or message.If the device is offline, the remote erase begins the next time it’s online. You’ll receive an email when the device is erased.
    When the device is erased, click Remove from Account.All your content is erased and someone else can now activate the device.
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • Can you add audio tracks as selectable menu items on a dvd? I shot a wedding where the church had its own set up to record audio. I'm trying to make those songs performed by the artists available for viewers of the dvd to select for listening.?

    I'm trying to make audio (MP3) tracks available for viewers of this Wedding dvd to select for listening. Is this possible in iDVD?

    You will need to create a slide show for each of those songs with a minimum of 1 photo per slideshow and add the song to the slideshow audio bin. Set the audio to Fit to Music.
    In your top/main menu add a submenu for the list of songs.
    Add a slideshow for each song with the "+" button at the bottom:
    Select the link in the menu and rename it for the song used in the slideshow.  You can create a slide image for each song with the song name, composer, singer, etc. on the image to be used for the slideshow  An image editor or Pages can be used for that and then convert to a jpeg file for use in iDVD.
    The song/playlist menu could look like this depending on the theme you choose:
    OT

  • Trying to make sense of div tags and css

    i know that i am a few years late here, but i am looking ot make the migration from using tables and switching over to div tags and css. i have watched a few tutorials on you tube and am trying to understand everything.
    please tell me if this is correct.  a div tag is basically a table and css is what is used to style that div tag to meet your needs, is this a correct assumption??
    if you go to my current site www.tankinz.com you can clearly see that the site is made up of tables, basically these boxes or tables contain a different item or package that a customer can click on and buy.  by using div tags and css would each of these boxes, or tables be their own div?
    sorry for sounding a bit moronic but i am trying to make sense of all of this.
    please help!

    Markup (html) contains elements, such as html, body, h1, h2, p, span, div and so forth. Hence a <div>-tag is part of an element; the other part being the </div>-tag.
    The element structure of many web sites is basically (using HTML5 element names)
    html
         head
         body
              header
              nav
              aside
              article
              footer
    These elements can be positioned and styled using style rules (css). Depending on the style rules, the above structure can take on many different styles, without ever touching the markup.
    Have a look here for a simple two-column layout using the same structure as above http://www.456bereastreet.com/lab/developing_with_web_standards/csslayout/2-col/

  • Hey I want to know what resolution a personas 3000x 200x is because I am trying to make one, but the middle part of the picure is movin to the left so some thing is wrong with resolution and interpolation. PS, I use Gimp.

    I use Debian and Gimp program to make my own personas but it seem like I have to know what resolution or interpolation is needed for the best result. I am trying to make one in size of 3000px wide x 200px high but don't know what resolution and interpolation is matching the requirements of Firefox or personas. For ex: in Gimp when scaling an image the interpolation possibilities are 4 like:
    None
    Linear
    Cubic
    Sync

    Try the Personas forum.
    * https://forums.mozilla.org/addons/viewforum.php?f=30

  • Something weird when trying to make a sphere in illustrator cs4

    I'm trying to make a sphere in CS4 out of a revolved semicircle and apply a pattern on it. But after I press revolve and try to visualize the map art, so that I can place the pattern on the sphere, the map art doesn't fit precisely on the object. The gridded sphere is displaced leftwards and upwards from the original sphere. Therefore, I can't apply the pattern as I want to.
    Aron

    Igorbuitendijk wrote:
    The testing serverfolder is:http://www.checksite.eu:2222/public_htmlThe URL prefix is:http://www.checksite.eu:2222/public_html
    When I leave out the 2222,Dreamweaver can't make a connection to the server.
    I don't know about the use of port 2222, but your testing server definition is completely wrong.
    The testing server folder must be a physical path, not a URL. And the URL prefix must be a valid URL. public_html is the name of the web server's document root, it should never be part of a URL.
    Judging from the details you have given here, you are using your remote server for testing. In the Testing server section of the site definition, set Access to FTP. The value of Host directory should be what your hosting company tells you to use when logging in. For some hosting companies, you use public_html on its own. Other companies tell you to leave the value blank or to use just /.
    The URL prefix is just the URL for the site.

  • How i can make  my own connection in java source of a jsp page

    How i can make my own connection in java source of a jsp page (How to get connection from JNDI datasource address) ?
    imagine that i have a rowset in a web page , now i want to do some operation using
    plain JDBC , so i will need a connection object.
    I tried to get one of my rowsets connection but it return null ?
    what is best way to retrive a connection from JNDI datasource that we define for our project?
    for example if i have
    myRowSet.setDataSourceName("java:comp/env/jdbc/be");
    in web page constructor
    now i want a pure connection from the same datasource ? JNDI
    Thank you

    It is not hard to get your own connection from datasource.
    in your case you need to do like the the following code.
    i provide sample to show you how to catch the exception and create an statement .
    Connection con =null;
    try{
    InitialContext ctx = new InitialContext();
    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/be");
    con = ds.getConnection();
    java.sql.Statement st =con.createStatement();
    }catch(SQLException sqlex){
    sqlex.printStackTrace();
    sqlex.getNextException().printStackTrace();
    catch(NamingException nex){
    nex.printStackTrace();
    hth
    Masoud kalali

Maybe you are looking for