Error on import statement.

I got compiler error for an import statement which is: import MyClass;
It said: '.' expected at the end of the statement. However, MyClass isn't any package. Also, I can compiler the same code with the import statement as above on other machine with no error. So, I'm thinking there might be some kind of settings for windows that I've done wrong.
I have my path point to jdk\bin and my classpath point to current directory. I'm using win2k + jdk1.3.1
Anyone has idea about this??
Cheers,

Didn't you ask this once before?
Anyway, the statementimport Myclass; is malformed. You cannot explictly import a member of the default package, and you don't need to, they are already imported as are those classes defined in your package and those classes defined in java.lang.
Chuck

Similar Messages

  • Javac(1.4.2) gives error in import statement

    Hi All,
    I am facing a surprising problem. I have 2 java class files. I write the import statement for second one in the first one. There is no package & these are in the same directory. I have compiled the second one. But when I try to compile the First one. Javac throws error at import statement like below :
    D:\Clubs\oct\6>javac -d . ManojTest.java
    ManojTest.java:1: '.' expected
    import SessionBean;
    ^
    1 error
    My Java Files are as below :
    import SessionBean;
    public class ManojTest
         public static void main(String args[])
    //ManojTest.java
    public class SessionBean
         public static void main(String args[])
    //SessionBean.java
    I have compiled SessionBean.java successfully but when I try to compile ManojTest.java I get error mentioned above.
    However this probelm comes when I use j2se 1.4.2.. but works in j2se 1.3.1..
    Another way could be I use package structure.
    But I can't do any of these, as I have to port my big project to j2se1.4.2.. from j2se1.3.1.. (Live project is running on Tomcat).
    Problems is similar in Unix & Windows both.
    Is this javac compiler issue or there is some setting which I can make.
    I have already included . (dot) in PATH & CLASSPATH environment varibales.
    Please help me out if there is any way around this, as i am stuck up in between
    thank you
    Manoj :confused:

    Use a package and then add that package in your classpathOr don't use a package, leave the file in the default (noname) package, and don't use the import statement. Java will find it in the default package without the import.
    Explicit import statements from the default package are no longer allowed

  • Error in IMPORT statement: Change of length on conversion.

    Hi this is an error i had when creating a source system for a client.
    Runtime Errors CONNE_IMPORT_CONVERSION_ERROR
    Occurred on 21.02.2005 at 14:08:20
    The error probably occurred when installing the
    R/3 system.
    When importing an object, conversion would result in a length change.
    You may able to find an interim solution to the problem
    in the SAP note system. If you have access to the note system yourself,
    use the following search criteria:
    "CONNE_IMPORT_CONVERSION_ERROR" C
    "CL_W3_API_TEMPLATE============CP " or "CL_W3_API_TEMPLATE============CM007 "
    "IF_W3_API_TEMPLATE~LOAD"
    Can anyone please help me .
    Thanks in Advance
    SHASH

    Hi All,
    Above mentioned note will help but this will help you....
    I got the solution for this issue for my kind of problem.
    In program RPU600BT_CONV_SINGLE_CL we commented the following
    START-OF-SELECTION.
    IF 1 = 0. MESSAGE e567(3g). ENDIF. "#EC *
    PERFORM append_message USING 1
    space
    '567' "report not necessary
    space
    space
    space
    space
    'P'.
    STOP. "check note 1314769 whether conversion is necessary
    After this execute the same program and we will get the old results get converted.
    And one more is we should be careful in checking SAPU & SPAD transaction codes. There shouldn't be any partially implemented notes.
    Think will help at least one.
    Regards
    Aditya Surapaneni

  • Error regarding import statements...

    Hi
    This seemed a bit wierd to me.
    The first code snippet makes sense but not the second one...
    This code snippet doesnt compile because of error "single-type import"
    import java.util.Iterator;
         import java.util.Vector;
         import mypkg.Vector;
         class t12 {}
    [t12.java:  java.util.Vector is already defined in a single-type import
              import mypkg.Vector;]
    2nd code snippet
    import java.util.Iterator;
         import java.util.*;
         import mypkg.Vector;
         class t12 {}
    Compiles properly..
    I am not very sure...shouldnt the comile flag this as well as error
    Anu thoughts on this???
    -sbelur

    This is fine:
    import java.util.*;
    import mypkg.Vector; because if you use the Vector class it will not be Ambigious to the compilier, because you have specifically stated what you wanted.
    When you do this:
    import java.util.Vector;
    import mypkg.Vector; The compiler doesn't know which one to use. Just like when you do this:
    import java.util.*;
    import mypkg.*;

  • Import Statement Error

    Does anyone know what is wrong with these import statement?
    import Reduction;
    import Mapper;
    import ApplyObj;
    import ApplyObjUnary;
    import java.lang.String;
    public class Driver{
    public static Driver me = new Driver();
    public static void main(String[] args){
    int i;
    I places all my *.java file in the same directory as Driver.java
    But when i try to compile Driver.java, it says :-
    C:\assignment1>javac Driver.java
    Driver.java:10: '.' expected
    import Reduction;
    ^
    Driver.java:11: '.' expected
    import Mapper;
    ^
    Driver.java:12: '.' expected
    import ApplyObj;
    ^
    Driver.java:13: '.' expected
    import ApplyObjUnary;
    ^
    4 errors
    I set my class path as
    C:\>SET CLASSPATH = .;C:\j2sdk1.4.0_01;c:\assignment1
    Apparently, the current directory has been set and my assignment1 directory has been set.
    Did i miss out anything? Why does it can't recognize the existence of other class file in the same directory?
    thanks.

    You don't need to import classes that are in the default package (i.e. you didn't put them in a package). And in Java 1.4, you can't import them. Just remove the import statements, you shouldn't need them.

  • Length error occurred during in IMPORT statement

    Dear Friends,
    (length error occurred during in IMPORT statement),when im using the SUBMIT syntax..can i know what is the reason.
    Thanks
    Rajkumar.A

    Hello,
    I would like to know how did you solve the issue as i came across the same issue.
    Thanks,
    FBK

  • Length error occured in IMPORT statement

    Hello everyone,
    i hv one requirment in PO print(ME23N). in po print asset no nt display without changing other format.
    so that i first copy both smartform and driver program, in that i made certain changes such that i declare the patameter p_ebeln and i comment to data statement of p_ebeln & p_ebeln = nest-objky.
    then i join asset no (anek-anln1) with the help of inner join. then in smartform i gave condition that if bsart = 'ZCAP'
    wa_final-anln1 = gv_anln1.
    endif.
    i import gv_anln1 in smartform and exported in deriver program.
    both are synthetically currect but when i gave print preview dump is occured.
    length error occured in IMPORT statement
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_IMPORT_MISMATCH_ERROR', was
         not caught in
        procedure "%GLOBAL_INIT" "(FORM)", nor was it propagated by a RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        During import the system discovered that the target object has
        a different length than the object to be imported.
    what i do?

    Hello,
    can u send me coding for that?
    program line is already created for that
    and their first coding is like that,
    if gv_bsart = 'ZCAP'.
    wa_final-matnr = space.
    endif.
    and in text they fetch matnr no.
    but as per requirement they want asset no when bsart = 'ZCAP'
    how that asset no will come.
    matnr comes there is bsart is other that ZCAP, but bsart = ZCAP they want asset no instead of matnr.

  • Length error occurred in IMPORT statement.

    Hi All,
               while exexuting a program i got dump saying that Length error occurred in IMPORT statement. through ST22 i came to know that both import and export structres are not same. Import structure is longer than the export structure.
             I tried in SDN but i coudnt find any solution. can you please suggest how to solve this.
    Thanks in advance,
    Sreekala.

    Hi,
    Maybe what you can do si....
    Program X
    data: v_var(20) type c.
    export v_var.
    Program Y
    data: v_var(20) type c,
             v_var2(50) type c.
    import v_var.
    v_var2 = v_var.
    Create a variable that is exactly the same with the exporting parameter, then just assign it to a local variable declared in the 2nd program.
    Hope this helps.
    Benedict

  • JSP import Statement importing a Class File giving ERROR

    Hey guys,
    There is a problem to which I dont know the reason,
    Consider the code below:
    <%@ import Converter, ConverterHome %>
    It gives me a Compile Time error of this type:
    '.' Required in import Converter ;
    but when i put these classes in a package suppose "converter"
    and the above import statement like this :
    <%@ import converter.Converter,converter.ConverterHome%>
    It gives me no error
    So whats the reason behind this? Cant I compile a JSP program by refrencing classes without in any package?
    please Reply
    Thanks in advance..

    So whats the reason behind this?
    Cant I compile a JSP program by refrencing classes without in any package?No, I do not beleive you can, is you are using Java 1.4. In 1.4, you can only reference classes in the Default Package (none) from other classes in the default package. If you are in a package, then you can not import from the default package. And this is for ALL java classes, not just JSP and Serlets. Since the JSP servlet would be part of a package (which depends on the server you are using) you will need to put your classes into packages to import them...

  • Import statement giving error

    Hi All,
    I am writing a JSP page, and need to instantiate an object of a certain class within my package, in my JSP page.
    How do I do that? Do i use the <%import = "Myclass.class" %>
    I am using Sun Forte.. and the directory is myprojects/test/Classes/MyClass.java
    so how would the import statement look like?
    Thanks
    Kal.

    Kal,
    You would use the page directive with the import attribute. It looks like this: <%@page import="MyPackage.MyClass"%> or if your class is in the default package <%@page import="MyClass"%>. It is suggested that all classes used in JSP be packaged. (That is they include the package statement in thier source file and reside in a directory structure resembling the package name.)
    Cliff

  • Filename in import statement

    Hi srinivas bobbala,
    Thank you for your response.But I think my quesition was not clear.My ques... is for suppose there is one datafile for importing like.. "datafile_21" Here my intention is it takes file from datafile_21 only but it appears in import statement like datafile_21<<curmon>>.
    import database sample.sample data from data_file "c:\\ABC\datafile_21_AUG.txt" using server rules_file datafile on error abort;
    In this it takes datafile from datafile_21.But it appears like datafile_21_AUG in import statement.This AUG coming from batch file.
    Essmsh c:\\ABC\loadmxl.mxl %curmon%

    No it is not possible.
    I assume the data file "datafile_21" is first renamed to datafile_21_${CurrMth} in the batchscript.
    After that this data file *datafile_21_${CurrMth}* is pointed in the import statement.
    In the logs you will see this file as datafile_21_Aug.

  • Error while importing a new CERT in oracle 10G B2B

    Hi All,
    I am trying to upload a new certificate in 10 G B2B server, its not updating a certificate, I am facing the below error while importing
    Error
    An error occurred when updating the certificate.
    Error -: AIP-16001: The model validation engine failed due to an internal system error.
    Error -: AIP-11052: Writing following objects: Certificate failed due to following constraint violation: CERTIFICATE. CAN NOT UPDATE UNVERSIONABLE OBJECT IN A VALIDATED CONFIGURATION.
    Note: Please help me in resolving this ASAP.
    Regards
    Sai

    Hi Sai,
    It seems you are updating certificate in a delivery channel which is being used in a validated (or may be deployed) agreement. Please retire/purge any deployed configuration which is using that delivery channel and also make sure no such agreement is in valid state(which is using this delivery channel).
    Regards,
    Anuj

  • Error while importing N Accounts to 1 Address with UCM Batch Manager

    Hi,
    I got a problem with importing Accounts using the UCM Batch Manager. Previous steps were loading the EIM Tables EIM_UCM_ORG and EIM_UCM_ADRPER. To associate addresses I used the column EIM_UCM_ADRPER.PAR_UCM_ACCNT_UID. No errors occured during an Enterprise Integration Mgr jobs to load the data into SDH tables.
    The error described below occurs if I have N Accounts using one Address. Example:
    h5. Account Name --> City --> Postal Code --> State --> Street
    Account #1 --- Munich --- 80331 --- N/A --- Some Street 1
    Account #2 --- Munich --- 80331 --- N/A --- Some Street 1
    h5. If I try to get the Accounts into the Base tables using the UCM Batch Manager I get the following message from the log file:
    ObjMgrBusCompLog     Error     1     000003084c571160:0     2010-08-03 19:11:14     (odbccon.cpp (2097)) SBL-DBC-00111: An error has occurred writing to a record.
    Please continue or ask your systems administrator to check your application configuration if the problem persists.
    DBCLog     DBCLogError     1     000003084c571160:0     2010-08-03 19:11:14     SQLError: [23000],[Microsoft][SQL Native Client][SQL Server]Cannot insert duplicate key row in object 'dbo.S_ADDR_PER'-Objekt with unique index 'S_ADDR_PER_U1'.
    DBCLog     DBCLogError     1     000003084c571160:0     2010-08-03 19:11:14     SQLError: [01000],[Microsoft][SQL Native Client][SQL Server]The statement has been terminated.
    ObjMgrBusCompLog     Error     1     000003084c571160:0     2010-08-03 19:11:14     (sqlobj.cpp (43735)) SBL-DAT-00381: A record that contains identical values to the record you have created already exists.
    If you would like to enter a new record, please ensure that the field values are unique.
    ObjMgrLog     Error     1     000003084c571160:0     2010-08-03 19:11:14     (adptutils.cpp (5715)) SBL-EAI-04381: For instance of Integration Component 'Account_Business Address', using user key '[City] = "Munich" AND [Postal Code] = "80331" AND [State] = "N/A" AND [Street Address] = "Some Street 1"', a record with identical values already exists in the Siebel database.
    Please ensure that the field values in the input message are unique.
    EAISiebAdpt     EAISiebAdptErr     1     000003084c571160:0     2010-08-03 19:11:15     [0] For instance of Integration Component 'Account_Business Address', using user key '[City] = "Munich" AND [Postal Code] = "80331" AND [State] = "N/A" AND [Street Address] = "Some Street 1"', a record with identical values already exists in the Siebel database.
    Please ensure that the field values in the input message are unique.(SBL-EAI-04381) (0x75017d)
    h5. Result:
    Account #1 gets inserted with Record Type: "Source-Insert"
    Account #2 will not be imported and gets Record Type: "Incomplete"
    Does anyone know how to handle this problem?
    Many Thanks
    Sebastian
    Edited by: user13098670 on 04.08.2010 06:34

    I have selected the option
    Add new metadata and replace existing objetcs. But it is not importing. Also I tried other options like
    1. deleting the existing mapping and tried.
    2. Putting the mapping in recycle bin and try.
    3. Take it from recycle bin.Even during taking it from recycle it is giving me the following error .
    Error occurred importing mapping
    <DWH_CMMDTY_INVC_FACT_MAP/DWH_CMMDTY_INVC_FACT_MAP>
    (at line 141).
    Detailed Error Message:
    API2014: Internal Error: Error in createStage:
    In above all cases it is giving me the error.
    Could you please help?

  • Import statement is not working

    hi everybody,
    I have a directory under which I have a number of sub-directories. Lets call this directory "parent_directory". under this directory I have another directory called "child_1". Under "child_1" I have another subdirectory called "child_2". Now I have a code in child_2 that has the following statement:
    import program_1;
    //this is a program present in the parent directory. lets call it
    //program_1.java
    when I am compiling I am getting an error saying:
    program_2.java:28: '.' expected
    import program_1;
    ^
    1 error
    program_2.java is the program present in child_2 in which I have included the import statement.
    If I change the ";" to "." then again error appears as the import statement only needs the name of the class and doesnot need the extension.
    I will be very grateful to you if you could please suggest me a way around this.

    This questions belongs in the "New to Java" forum ...
    sigh
    Anyways, import works on package names with trailing * or full qualified class names, e.g.import mypackage1.*; // imports all classes in mypackage1
    import mypackage2.MyClass2; // imports MyClass2 from mypackage2So instead of import program_1; you need to do
    1. ensure that program_1 is in some package
    2. ensure that your directory structure mirrors your package structure (same names!)
    3. ensure that your CLASSPATH is either not set at all or points to the parent dir of your topmost package
    Example:
    Directory structure:C:\tmp\java\top\
    C:\tmp\java\top\MyClass1.java
    C:\tmp\java\top\bottom\
    C:\tmp\java\top\bottom\MyClass2.java
    CLASSPATH=".;<java install dir>\jre\lib\rt.jar;C:\tmp\java"Source for MyClass1.java:package top;
    public class MyClass1 {
    }Source for MyClass2.java:package top.bottom;
    import top.MyClass1;
    public class MyClass2 {
      private MyClass1 myClass1;
    }

  • Import statement and directory structure

    First of all, sorry for such a long post, I believe part of it is because I am unsure of the concept of importing in Java. Secondly, Thanks to anyone who can ultimately enlighten me to the concept of import. I did ask this question before in the "erorr and error handling" forum, and the people who have helped me there did a great job. But, I believe I require a little more clarification and thus have decided to post here.
    Anyhow, my question..
    Could someone explain to me the concept of the import statement, or direct me to a webpage with sort of explanation for newbies? For some reason, I am having a hard time grasping the concept.
    As I understand it, the import statement in Java, is very similar to the namespace keyword in C. That is to say, import doesn't actually "import" any source code, the way that the #include statement does in C.
    So I suppose what my question is, say I have a java class file like below:
    //filename: sentence.java
    //located: c:\school\csc365
    package csc365;
    class sentence
    //some variables here..
    //some constructor here..
    //some methods here..
    And some sample program like the one below which implements the above..
    //filename: test.java
    //located: c:\school\csc365
    import csc365.*;
    import java.io.*;
    class test.java
    //creates some sentence object
    //uses the object's methods
    //some other things.
    As I understand it, the test.java file should not compile because the csc365 package is not in the correct directory. (assuming of course, the classpath is like c:\school\csc365;c:\school )
    But, ... where then should the sentence.java be located? In a subdirectory of c:\school called csc365 (i.e c:\school\csc365\) ?
    And thus that would mean the test.java file could be located anywhere on the hard drive?
    I suppose, I just need a little clarification on the correlation between a package's "name" (i.e package csc365; ) and its corresponding directory's name, and also how the javac compiler searches the classpath for java classes.
    ..So, theoretically if I were to set the classpath to look in every conceivable directory(provided the directory names were all unique) of the harddrive, then I could compile a test.java anywhere?
    As a note: I have been able to get the test.java file to compile, by leaving out the import statement in the test.java file, and also leaving out the package statement for the sentence class, but I assume this is because the files are defaulted to the same package?

    Hi Mary,
    No, import isn't analogous to C++ namespace - Java package is closer to the namespace mark.
    import is just a convenience for the programmer. You can go your whole Java career without ever writing an import statement if you wish. All that means is that you'll have to type out the fully-resolved class name every time you want to use a class that's in a package other than java.lang. Example:
    // NOTE: No import statements
    public class Family
       // NOTE: fully-resolved class names
       private java.util.List children = new java.util.ArrayList();
    }If you use the import statement, you can save yourself from typing:
    import java.util.ArrayList;
    import java.util.List;
    public class Family
       // NOTE: fully-resolved class names
       private List children = new ArrayList();
    }import isn't the same as class loader. It does not bring in any source code at all.
    import comes into play when you're compiling or running your code. Java will check to make sure that any "shorthand" class names you give it live in one of the packages you've imported. If it can't find a matching fully-resolved class name, it'll give you a message like "Symbol not found" or something like that.
    I arrange Java source in a directory structure that matches the package structure in the .class files.
    If I've got a Java source file like this:
    package foo.bar;
    public class Baz
       public static void main(String [] args)
            Baz baz = new Baz();
            System.out.println(baz);
       public String toString()
           return "I am a Baz";
    }I'll store it in a directory structure like this:
    root
    +---classes
    +---src
          +---foo
               +---bar
                    +---Baz.javaWhen I compile, I go to root and compile by typing this:
    javac -d classes foo/bar/*.javaI can run the code from root by typing:
    java -classpath classes foo.bar.BazI hope this wasn't patronizing or beneath you. I don't mean to be insulting. - MOD

Maybe you are looking for

  • Getting error in IC agent business role while loading components.

    The user has been allowed and access to all business role.user are using all business roles but when user click on the IC agent business role the following error arise. Cannot display view CRMCMP_BPIDENT/BuPaMultipleLayoutVS of UI Component CRMCMP_BP

  • Cant send my photos by email from computor.

    when I want to send my photos silverlight says it has a problem & shuts down/stops transmission. Either this is changed or firefox goes!!!

  • CD Text not showing up on burned cd's.

    When I burn a cd, the cd text is not showing up even though I have the include dc text option checked. Any suggestions?

  • Complex HSRP Design Issue

    I work for a company and we want to implement HSRP. We are a small ISP and most of our customers come into a fastethernet port on subinterfaces. We have fastethernet 0/1.100 through 0/1.125. So 25 customers, each with their own network addressing com

  • Trying to transfer Hi-MiniDisc files to my MacBook Pro

    Hi,I have a Hi-MiniDisc MZ-NH700 with a lot of music,and I´m trying to transfer it to my Macbook Pro with an OS X Lion 10.7.4 software. I connect the Hi-MiniDisc via USB port but my Mac didn´t detect it...do I need something to make it work? ...anybo