Java Newbie Question - the import statement

Hi Geeks,
I have a problem for importing a java .class in my project. This latter is named "Tedetis_New". Inside it, I created a "src" folder containing all the source code of the application. I import a jar file inside the parent directory of "src" (i.e. at the root of the project). Inside this jar archive, two classes (.class files) are not placed inside a package (default package according to eclipse), let's name one toto.class. So when I want to import toto.class from a file inside the src directory I simply do "import toto.class" but this statement doesn't work ! I don't manage to import my toto.class so ... what do you propose for this ?
Thanks.

Don't use the "default" class for anything serious;
you can't import such a class.Er, package maybe?Yes, I was editing my reply while you replied to my reply so I couldn't
edit my little blooper in my reply anymore; thank you very much Sir ;-)
kind regards,
JosI entered that response as quickly as I could, for just that reason. I
thought you might notice and try to correct it, and I wanted to preserve
your fuckupus maximus for all eternity.
Everyone gather round and taunt Jos! Wave your private parts at his
auntie! Fart in his general direction!
Now, aren't you glad you didn't say "Jehovah"?I already knew that you were the one who invented amiability ;-)
kind regards,
Jehov^H^H^H^Hos

Similar Messages

  • Newbie question about import statement

    Lets say for example I have a class A and a class B.
    Then lets say I import class A into class B.
    If I instantiate some objects and methods in class A
    Will I be able to access them in class B.
    Thanks gemann

    Imports are used to import classed from another package.
    Conside a package named package1 and class named A in it.
    package package1;
    public class A{
      //public method
      public void publicmethod() {}
      //private method
      private void privatemethod() {}
      //default method
      void defaultmethod(){}
      //protected method
      void portectedmethod(){}
    }Now conside another package named package2 having a class B.. and you want to make an object of class A and want to call its method..
    package package2;
    import  package1.A;  // or import package1.*   it imoprts every class in this package
    class B{
    B(){
    A a=new A() ; // possible since we imported it..
    a.publicmethod() // possible since it is public method
    a.defaultmethod()// Not possible. since it is a this is in a different package
    a.protectedmethod()// Not possible since this is in  a different package, and this is not a derived a derived class of B
    a.privatemethod() // Not possible since it is private
    }Hope it is clear now..
    appu

  • How to organize the import statements in FXML Files?

    Hello,
    I'm a user of NetBeans IDE and it can organize the import statements in *.java files. Now, I'm using JavaFX and editing the *.fxml files as well. I want to know how to organize the import statements in *.fxml files?
    Thanks a lot.

    You should use Scene Builder, it will make all these import statements for you.
    Moreover, it will greatly simplify the writing of your FXML files, since you only have to Drag&Drop JavaFX objects on the scene. Then, it automatically generates FXML files.

  • Please explain the IMPORT statement?

    I have been searching for information on the import statement, but can't seem to locate it. I understand how to use import, but I would like to know, in detail, exactly what it does.
    When I import, for example; "java.awt.*", I would expect this statement to import ALL of the classes define under "java.awt". However, I notice in the DiveLog class, that I must also import "java.awt.event.*". This is confusing to me.
    Can someone either explain this for me, or point me to the imort documentation?

    aye - what yawmark says. And also be aware that import doesn't really "import" any source (not the way #include does, if'n you're an old school C coder). It's just there to shorten typing. You can either type "java.io.IOException" a lot, or import java.io.IOException and get away with just typing "IOException". But you've just "imported" the namespace, not any kind of source.
    Make sense?
    Lee

  • Question about import statements

    Why is it that I must have the import statement on the
    same frame
    and same layer
    as the AS code that utilizes the Class that I am importing?
    At least that is how it appears.

    Because that is how it works.
    Remember, import doesn't actually "import" anything. It is
    just a shortcut so you don't have to type the whole package name
    every time you use the coded in your example.
    It is actually kind of nice when you come back to code later
    or if you open somebody else's code (that you have to update or
    change) and to see at the top, "Oh, this bit of code has a reliance
    on class blah.blah.Yadda." In a way it kind of helps enforce a bit
    of good coding practice.

  • Some questions on import statements.

    When I see
    import java.awt.*
    import java.awt.event.*
    am I on track interpreting this to mean that you want to be able to use any of the classes found in package java.awt?
    why would import java.awt.event.* be necessary if event is a class in the java.awt.* package you're importing in the second import statement up above?
    does * mean like a "wildcard" which allows you to utilize
    anything that is part of java.awt?

    It allows you to use any of the classes in that directory, but not any classes in sub-directories of that directory.

  • Help with the import statement

    Hello,
    i have a question, how would you start a simple program
    that it doesn't involve graphics or anything like that.
    A simple program that for ex. it would increment and then dicrement the
    enetered number.
    What would you write after import_______________;
    and how would you initialize the variables that you use.
    Thanks in advance!!!

    I'm not sure that you understand what an import statment does.
    Every class that you want to use must be imported. For example in this the class Integer must be imported
    Integer myinteger = new Integer(5);so every time you use the word "new" that class must be imported.
    To make our lives a little easier java will automatically include the java.lang.* files so all java programs have the line:
    import java.lang.*;even though you don't see it.
    If you want to use other classes you must find out what package they are in and import that class or it's entire package.
    For example if you want to get user input you would probably want to look at the java.io package.
    It will take some time to get a good feel for the packages and what classes are available, but spend some time each day or a couple time a week looking through the java API's.
    hope that helps.

  • About the import statement

    Hi, im trying to use NumberFormat to format a double variable.
    How do i know if i need to use the "import java.someclass" statement or not? thanks for reading.

    NumberFormat is in the java.text package, so you either have to import it via:
    import java.text.NumberFormat;
    or
    import java.text.*;
    or else everywhere you use it fully qualify it as java.text.NumberFormat

  • Newbie question about switch statement

    Lets say you have a loop and inside the loop you have a switch statement, how do you BREAK out of the outer loop?
    for (i=0....) {
    switch {
    case 11:
    .... some stuff
    break; <==== HOW DO I BREAK OUT OF THE for loop here?

    In standard C and standard C++ the break statement terminates the nearest enclosing loop and only that loop; i.e. control transfers to the first statement following the loop. I think there are C or C++ extensions that allow loop tags which may be used with a break to specify which loop to drop through, but I don't think these are supported by gcc, and they would certainly be very non-portable.
    There are several common ways to drop out of one or more outer loops. In many cases, there's nothing else in the loop following the switch so you can simply write
    switch (condition) {
    default:
    case 0:
    break;
    // other case statements here
    break;
    Else you can declare a loop control var and use the continue statement like this:
    for (i=0; i<jMax && !bDone; i++) {
    switch (condition) {
    default:
    case 0:
    bDone++; continue;
    // other case statements
    If you need to escape several loops and/or don't want to use loop control vars, you might consider structuring the code so you can use return to terminate the entire function. In the worst case of a very complex structure that you don't know how to simplify with a helper function, you can always resort to a goto:
    switch (condition) {
    default:
    case 0:
    goto escape;
    // other case statements here
    // remainder of code inside nested loops here
    escape: <first statement following the outermost loop>;
    Note that the statement following the escape label is always executed; i.e. when execution skips the goto it's as if the statement following escape was unlabeled. Use goto sparingly of course, since it's an artifact of unstructured programming. But when you really need a goto, it can make your code much easier to maintain.

  • Newbie question :- An IN statement question

    I have the following issue.
    I want to use an IN statement (As below), This will enable the user to enter upto 5 serial numbers.
    select col.contract, col.order_no, col.customer_no, ci.name Customer_Name, odn.ship_address1, odn.ship_address2, odn.ship_zip_code, odn.ship_city, odn.ship_county, co.customer_po_no, col.part_no, col.catalog_desc Description, ith.serial_no,
    col.real_ship_date Ship_Date
    from
    customer_order_line col,
    customer_info ci,
    inventory_transaction_hist ith,
    customer_order co,
    customer_order_deliv_note odn
    where
    col.customer_no = ci.customer_id
    and
    col.contract = ith.contract
    and
    col.order_no = ith.order_no
    and
    col.part_no = ith.part_no
    and
    col.order_no = co.order_no
    and
    col.contract = co.contract
    and
    col.contract = odn.contract(+)
    and
    col.order_no = odn.order_no(+)
    and
    ith.serial_no IN ('&S1' , '&S2' , '&S3' , '&S4' , '&S5')
    and
    (('&FROM_DATE') is null or ('&TO_DATE') is null or
    dated between to_date('&FROM_DATE','DD/MM/YYYY') and to_date('&TO_DATE','DD/MM/YYYY') + ( 1 - 1/ ( 60*60*24 )))
    The problem is that if they don't enter any serial numbers it return no values.. (it should do).. How can I I amend this SQl so if S1/2/3/4/5 has null values it does return some data
    Message was edited by:
    HoLy_PiLgRiM

    Hi,
    Well it will return customer order's, If I took out the IN statement and run it.. it will promt me for a date range and it will return a load of Customer Orders within that date range..
    With the IN statement, If I put a serial number and and specify a date range it will only bring back customers orders with that serial number in them.. The problem is if they don't specify a serial number and enter a date range nothing comes back ? It like I need to enter and if null blah blah

  • Java newbie questions...Setting the classpath in Unix

    When you set the classpath, how do you include anything already in the classpath? For instance, if your profile sets your classpath to
    "/home/weblogic/:home/weblogic/weblogic.jar, and you want to add MyJar.jar to it, can you enter:
    export classpath=~:MyJar.jar
    My question really boils down to how do you prefix the existing CLASSPATH environment variable to any new classes or jars you want to add to it. I think it's the tilde, but I'm not sure.

    In csh, the CLASSPATH environment variable is modified with the setenv command. The format is:
    setenv CLASSPATH path1:path2
    In sh, the CLASSPATH environment variable can be modified with these commands:
    CLASSPATH = path1:path2:...
    export CLASSPATH
    ====
    (From the Sun documentation)
    or, in sh,
    export CLASSPATH=path1:path2
    should work

  • Error showing in the import statement

    Hi there........
    I am working on mobile project of expense managemnt.
    in that code i started with following statements.
    import java.sql.*;
    i am using the CDC 1.0 toolkit.
    it shows the error that statement does not exist & errors for class.
    Is it necessary to use additional API for implementing embedded SQL in mobile.
    SO,
    please tell me immediately

    hi thanks for your reply
    i have loaded tomcat4.1 exe -- for windows i am starting the tomcat server by clicking from the start menu..
    i dint set any env variable .. tell me how to set...
    regards
    ijay

  • Question about import statement

    Hi all!
    I was wondering if a line like this:
    import java.io.*imports all classes from java.io or just the classes needed by your program (the classes you actually using in your code). Can anyone give me a little hint on that?

    The way I understand it is that it simply makes the
    classes in that package 'visible'. This means that you
    don't have to type the fully qualified name each timeOh, yeah. I was thinking too much in C and it's #include.
    Thanks :-)

  • The 'import' statement

    Dear Friends and fellow Javatizens....
    I have a package called 'Tester'. In this package i have two classes caled 'Fruit' and 'Food'.
    In the 'Fruit' class I have an integer varibale 'i' which is assigned the value of 5.
    Now create another class called 'Food' and import the 'Frult' class as 'import Tester.Fruit'. I come up with a println statement in the 'Food' class that says:
    System.out.println("The value of i is " + i);
    I am getting an error saying that variable 'i' can't be found in the class 'Food'. Why is this the case when I have already imported the class 'Fruit' which already has the integer 'i' declared as a public int?
    It will be very useful for me if somebody were to shed light on this matter. Thank you very much.
    regards
    Compiler

    when you type import you say to the compiler that you dont want to put the full class name every time you use that class.
    System.out.println("The value of i is " + i);That code prints the value of the variable i, but the variable i is not declared.
    The class Fruit has that variable, but if you want to use you should type
    Fruit f = new Fruit();
    System.out.println("The value of i is " + f.i);or
    System.out.println("The value of i is " + Fruit.i); // if i is staticI think thats it!

  • Including class files withouth the import statement

    I have been working on a project for my computer science class in which i have to design a "Projectile" class. However, when i attempt to use that class in a program, my compiler can't find the file even if it is in the same directory. I think i may have a problem with my classpath, but i am not sure. I don't know much about the way the compiler works. If anyone could give me a hint that would be great. Thanks

    You'll probably need to post more information, such as the command you are entering, the exact error message, and perhaps part of the code - at least the class definition.
    It sounds like a Classpath problem, or perhaps you aren't specifying the class correctly. The classes must be in the same package or you must import the_package.Projectile into the other class. The compiler will attempt to find the Projectile class by looking into the directories that are in the Classpath. You could try "javac -classpath . the_class.java"

Maybe you are looking for