Problems importing my class

Hello
I'm writting just a simple game to get me back into java using Linux 7.0
When using windows a while back it compile ok buy wont on my Linux
I have provided just the import statements because i know the rest of the code is fine.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.swing.*;
import java.TicTacDlg;
Error i get is:
TTacToe.java:12: '.' expected
import TicTacDlg;
^
1 error
TicTacDlg.java is in DIR is in '/root/java' along with the rest of the classes.
I have tried setting CLASSPATH to above path and '/usr/java/j2sdk1.4.0/lib/tlib/tools.jar'
Is it correct to set CLASSPATH to tools.jar, as u do in windows?
I'm using the beta version of java 2 SDK 1.4 standard addition
I'm

Sorry, the statement:
import .java.TicTacDlg was actually a typo made when typing this message and is actually:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.swing.*;
import TicTacDlg;
Also as i'm have not done any java since early 1999 in UNI. I have noticed newly introduced words i.e "package" please explain.
Is a package just another word for classes, such as TicTacDlg.java as i have defined.
In those days we were using JSDK 1.2 and did not use the word package. Please give example if can.
Thanks

Similar Messages

  • Problems importing a class with inner class

    Why can't I import a class so that I can use an (inner) static member class without naming the enclosing class. Put simply, I have:
    file C:\MyJava\Test\A:
    public class A {
      public static class B { }
    }file C:\MyJava\Test\C
    import A.*;
    public class C { }When I try to compile C (javac -classpath C:\MyJava\Test;. C.java) it fails with C.java:1: package A does not exist

    Class A must be in a package if you wish to import it. If you want to use the inner class, just import somepackage.A. You could then refer to A.B...
    HTH :o)

  • Problems importing servlet classes

    When I try to compile a bean which has import statements for importing servlet classes, I get the message that the class is not found in import when I compile the code. I have all these class files and I'm not sure whether I've placed them aptly. Please give me the details about placing the servlet classes and configuring my javac to import these classes.
    Thanks!

    If you place your classes in the %JAVA_HOME%/jre/lib/ext, they will be automatically accepted by the javac and the java. But, depending on the classes you use, it would be better to include them in %application path%/WEB-INF/lib, so they will only be used by that application.

  • Problems importing my classes

    Greetings!
    I am new to JSP and Struts. I need to use some of the classes I created in one of my JSP pages so I placed an import statement specifying the classes which I need. The problem is that each time I tried to view the page, I see this exception.
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\jakarta-tomcat-5.0.28\work\Catalina\localhost\DeveloperSkillPoolManagementSystem\org\apache\jsp\forms\AddSkill_jsp.java:8: 'class' or 'interface' expected
    import com.las.dspms.skill.*;
    ^
    1 error
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)The classes have been compiled and I am able use them in my Java codes, but not in my JSP pages.
    the import statement:
    <%@ page import="com.las.dspms.skill.*" %>

    Yeah, the package is present inside my WEB-INF/classes folder . I placed the import statement just after the java import statements.
    <%@ page import="java.util.List" %>
    // other java imports here
    <%@ page import="com.las.dspms.skill.*"%>

  • Having problem importing a class

    When I compile my program called Dic2.java, I get the following error:
    C:\Program Files\Java\jdk1.6.0_01\bin>javac Dic2.java
    Dic2.java:1: '.' expected
    import Entry;
    ^
    1 error
    I compiled my Entry class and it did just fine. Here is my code for Dic2.java:
    import Entry;
    public class Dic2
      protected Entry entries[];
      public Dic2(String puzzle)  // constructor
        if (puzzle == "unscramble")
          entries[0] = new Entry("stupid", "Insult");
          entries[1] = new Entry("monkey", "Zoo animal");
          entries[2] = new Entry("meerkat", "Animal Planet had a series set in the Kalahari Desert featuring this small furry animal");
          entries[3] = new Entry("burrow", "Where meerkats sleep and raise their pups");
          entries[4] = new Entry("boogers", "Gross things");
    }I don't know why my compiler wants a period. I hope you can help me. Your help will be greatly appreciated.

    I know you're gonna think I'm crazy, but I I've just started using jdk1.6.0_01 after years of using my more familiar jdk1.2.1. I'm used to compiling packages to jdk1.2.1/jre/classes/com/whatever. I have done similar programs using my own classes in my old version and didn't have to compile them to a package. Is this a newer requirement?
    Also, which path should I take to compile a class in the newer jdk1.6.0_01? It's all different from my old jdk1.2.1.

  • Problem importing classes and beans

    Hey there. Im having one major fustrating problem! When I code supporting classes and beans for my JSPs I get a code 500 internal server error when trying to import (via <%@ page import="class" %> and <jsp:useBean/>) Im storing my classes and beans in the WEB-INF folder and the calling JSPs are located in /ROOT/tests/8/jsp.jsp. Im using the following to import a class or bean:
    <%@ import="aClass" %>
    Seen as tho its in the WEB-INF folder I won't have to explicitly refer to where the class is located, just the class name.
    I never had this problem when I was using my hosting service. Its only on my localhost server in which I get the Internal Server error.
    Help appreciated, thx.
    PS: Im quite new to JSP/Java Servlet.

    import (via <%@ page import="class" %> and
    <jsp:useBean/>) Im storing my classes and beans in the
    WEB-INF folder try put your class file in WEB-INF/classes.
    or first put bean in the package, like WEB-INF/classes/packagename/beanclass
    in jsp page:
    <jsp:useBean id="Mybean" class="packagename.beanclass" scope="request" />
    Question: is /ROOT a context entry in your server.xml?
    Which JSP Container (version) you use? Maybe your localhost server's set up is different with your hosting.

  • Problem importing classes

    Hi, I've doing a simple program to read a file and output its content by using BufferedReader and readLine() methods. My executing program is "TestProgram.java" and it imports the class "InputFileReader" to use. I have all the files in the same directory C:\j2SDK1.4_0\bin.
    When I compile "TestProgram.java", it returns the error message : Cannot resolve symbol. Symbol : variable InputLineReader.
    Can someone help me with the problem? The 2 codes are provided below.
    // InputLineReader.java
    package bin;
    import java.io.*;
    import java.util.*;
    public class InputLineReader
         public static String lineRead (BufferedReader buff)
              String line = null;
              try {
              line = buff.readLine();
                   } catch(IOException e) {
              System.out.println("IO Error");
              return line;
    // TestProgram.java
    package bin;
    import java.io.*;
    import java.util.*;
    import bin.*;
    public final class TestProgram {
         public static void main (String[] args) {
              FileReader file = new FileReader ("strtestdata1.txt");
              BufferedReader buff = new BufferedReader(file);
              String output = null;
              output = InputLineReader.line;
              System.out.println(output);

    I Dont Know Exactly Why The Problem Is. .......
    Anyway here is class I have written that works ...
    It reads ffrom a while and writes to another file ..
    I hope you can get some useful info from it
    import java.io.*;
    // This class Attempts to read from a file containing text, line by line and
    // copy the contents to a new file ...................
    public class ReadAndWrite {
        // initialising variables
        private String textLine;
        int count;
        private LineNumberReader lineReader;
        private BufferedReader bReader;
        private BufferedWriter bWriter1, bWriter2;
        private File readFile, writeFile1, writeFile2;
        // constructor
        public ReadAndWrite(String pathRead, String pathWrite1, String pathWrite2) {
            try{
                readFile   = new File(pathRead);
                writeFile1 = new File(pathWrite1);
                writeFile2 = new File(pathWrite2);
                bReader    = new BufferedReader(new FileReader(readFile));
                lineReader = new LineNumberReader(bReader);
                bWriter1 = new BufferedWriter(new FileWriter(writeFile1));
                bWriter2 = new BufferedWriter(new FileWriter(writeFile2));
            }  catch (IOException e2) {
                // Catch any other IO exceptions.
                e2.printStackTrace();
        // method to read text line by line from a given file
        public String readFile()  {
            try{
                textLine = lineReader.readLine(); // reads one line and keeeps in buffer
            }  catch (FileNotFoundException e1) {
                // If this file does not exist
                System.err.println("File not found: " + readFile);
            } catch (IOException e2) {
                // Catch any other IO exceptions.
                e2.printStackTrace();
            return textLine;
        // method that writes the text to a new file line by line
        public void  writeFile(String textLine, int count1) {
            try{
                // prints the numbered text lines to the standard output
                System.out.println(count1 + "  " + textLine);
                // writes the numbered text lines to a new file
                bWriter1.write(lineReader.getLineNumber() + "  " + textLine); // text file
                bWriter1.newLine();
                bWriter2.write(lineReader.getLineNumber() + "  " + textLine); // word file
                bWriter2.newLine();
            } catch (IOException e2) {
                // Catch any other IO exceptions.
                e2.printStackTrace();
        // method calls readFile() and writeFile()
        public void process() {
            try{
                count = 1;
                // loop to call read and write methods
                // checks for text in the file = null
                do {
                    readFile();
                    if (textLine != null){
                        writeFile(textLine, count);
                        count ++;
                while (textLine != null);
                // closing all open streams when they are no longer needed
                lineReader.close();
                bWriter1.close();
                bWriter2.close();
            } catch (IOException e2) {
                // Catch any other IO exceptions.
                e2.printStackTrace();
    }

  • Importing Java class problem!

    Hello
    I have problem by Importing java class into form. When I select in Forms Builder from menu: Programs/Import Java Classes it returns error: PDE-UJI001 JVM not able to create!
    Can someone know what I must do to fix that problem?
    Thanks, Chrity

    It is a shame because it, probably, contains no special 1.5 new instruction at all.
    Maybe it would be possible to try replacing the current JDK/JRE of your <ORACLE_HOME>/jdk installation after a safe backup of course.
    You probably have a very little chance that it works, and it also won't be supported.
    Francois

  • Classpath problems when importing my classes

    I'm using a tutorial with sample programs dealing with bank accounts.
    I get this error:
    InterestBearingAccount.java [9:1] '.' expected
    import Account;
    ^
    1 error
    Errors compiling InterestBearingAccount.
    The Account class already exists in the current directory. I've tried everything as far as setting the classpath variable (nothing, just a period, period & slash, the actual complete path for the current directory, nothing works!!!!!). I also tried using -classpath (.) and the end of my javac command and that seemed to not work at all.
    The Java Coffee Break tutorial have some already compiled (*.class) files and they run fine. My *.java files are identical. In fact, I cut and pasted them so I know it's not a typo.
    My path is set to include the jdk1.4.0\bin directory and I've only begun to have problems now that I need to import existing classes into the programs.
    I should mention that I get the same error using Forte environment or doing it at the command prompt window. Please help.

    Thanks ATMGUY. I commented out the import statements in both InterestBearingAccount and AccountDemo and it worked fine. I guess the author of that tutorial was obviously not working with jdk 1.4.
    As far as using packages, com.kusek.bank would make a good package name then??
    The statement:
    package com.kusek.bank; OR a shorter version package kusek.bank;
    should be added to all three classes and no import statements would then be necessary, right??
    I just remember reading that it should be something unique as a good habit to get into.
    I'm trying to learn enough to make a useful GUI program for a special project so I probably should be using packages anyway when I get to that point.
    My programming backround is limited to procredural languages Basic, QBasic, Pascal, and Fortran and I find myself still wanting to think in those terms. I have read several web sites and worked through some basic examples but I still have much to learn. I once I can grasp how to write OOP style it would be nice to look at code for a somewhat detailed application (like a store checkout app) and have every line explained as to why it's there. I can see where it makes sense to have your GUI classes predefined (Swing), File I/O, serial port communications, and even things like this InterestBearingAccount example that extends from the Account class utilizing its basic attributes but overriding the constructors for the additional parameters (interest calculation) that are passed. How to take a common problem and go about creating a solution is what I need to see being done to help me.
    My telemetry project uses VHF radios with packet radio modems to monitor two diesel engines and turn one off if the other turns off. The modems have built in A/D data gathering and can also output control signals, they just need to be told what to do. I can manually use a Windows Hyperterminal session and type in "connect Engine1" and use commands to determine the A/D inputs "analog". The modems have built in end-to-end acknowledgement so the only think I need is an application than can be setup to run in the Startup folder to handle this. It would use a timer class to "poll" engine1 every 5-10 minutes and if it has stopped (based on the response of the "analog" command) I would "disconnect" from engine1 and "connect" to engine2 and send a "ctrl B off" or something similar. The standard responses from the modem should allow me just to send and recieve STRING data to and from the serial port and parse them as needed. I need at least this much but it shouldn't be too much harder to develop a way to reset the system(reverse of this) when that is required. I could also read a water pressure value at one of the locations and display that on the screen along with the current status of the engines (using values obtained from the "analog" command on the modems).
    The hardest part of OOP programming seems to be knowing what classes are already out there and knowing how to find them or apply them. I hope Swing has classes that provide for displaying values on the Windows taskbar (my motherboard monitor freeware displays temperature readings down on the taskbar). I appreciate all the help given here. It's almost like having a private tutor.
    randy

  • Problem When Import Java Class -compilation error

    Hi all
    I made a java class that has methods to return Screen width and Height .
    package tarek;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    public class Screen
    Dimension dim ;
    public Screen()
    dim = Toolkit.getDefaultToolkit().getScreenSize();
    public double getWidth()
    double w = dim.getWidth();
    return w;
    public double getHeight()
    double h=dim.getHeight();
    return h;
    I made the jar file " screen.jar" and make it ready to use in form builder
    I opened form builder and make import java class (From program>import java class>choose the class anc click import)
    The class now imported successfully and the PL/SQL package body is:
    PACKAGE Screen /* tarek.Screen */ IS
    -- DO NOT EDIT THIS FILE - it is machine generated!
    -- Constructor for signature ()V
    FUNCTION new RETURN ORA_JAVA.JOBJECT;
    -- Method: getHeight ()D
    FUNCTION getHeight(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER;
    -- Method: getWidth ()D
    FUNCTION getWidth(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER;
    END;
    Now I made a button on the form and i WRITE THIS CODE TO INVOKE THE CLASS on when_button_pressed
    DECLARE
         vScreen_Class ORA_JAVA.JOBJECT;     
    BEGIN
         vScreen_Class := SCREEN.NEW;
    END;
    My problem is I have compilation error
    error 306 AT LINE 5 , COLUMN 25
    wrong number or types of argument in call to "NEW"
    I do not know what is the reason of this compilation error?
    Is it because the method in java return "double datatype" while in oracle return "number datatype"
    Please help
    Edited by: [email protected] on Dec 28, 2009 10:24 AM

    Sarah, I ca not move my thread to JDeveloper because it is not java issue. The problem is with my PL/SQL code and the way I make Import Java class to forms Builder. The Java code is OK.
    Andreas Thank you so much for replying. In fact I made a full compile "Ctrl+Alt+K". but still error
    The following is the package Body
    PACKAGE BODY Screen IS
    -- DO NOT EDIT THIS FILE - it is machine generated!
    args JNI.ARGLIST;
    -- Constructor for signature ()V
    FUNCTION new RETURN ORA_JAVA.JOBJECT IS
    BEGIN
    args := NULL;
    RETURN (JNI.NEW_OBJECT('tarek/Screen', '()V', args));
    END;
    -- Method: getHeight ()D
    FUNCTION getHeight(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER IS
    BEGIN
    args := NULL;
    RETURN JNI.CALL_DOUBLE_METHOD(FALSE, obj, 'tarek/Screen', 'getHeight', '()D', args);
    END;
    -- Method: getWidth ()D
    FUNCTION getWidth(
    obj ORA_JAVA.JOBJECT) RETURN NUMBER IS
    BEGIN
    args := NULL;
    RETURN JNI.CALL_DOUBLE_METHOD(FALSE, obj, 'tarek/Screen', 'getWidth', '()D', args);
    END;
    BEGIN
    NULL;
    END;
    ---------------------------------------------------------------------------------

  • A  classpath error while  importing a class with @page import property

    Hi ,
    I am using Tomcat contaniner for jsp applications. I have developed a page that i have import a class. when i use
    <%@ page import="myclass" &>
    i got an error that myclass not found. I have placed into tomcat\webapps\myproject\web-inf\classes directory. So How will I set the classpath for myclass to work?
    thanks.

    I was able to simulate your problem when I created a mismatch in the case of the name of the class.
    for example if my program is called MyClass.java
    and in the import I do <@page import="myclass" %>
    Are you sure about the case of class name that you are using? Please check that the file is called myclass.java the class defined inside it is called myclass and the class file that is copied into the WEB-INF/classes directory is also myclass.class. There should be no difference in the case of the names. like MyClass.java or MyclaSS.class
    Other things to check are
    1. If myclass is defined in a package then you have to import with the package.
    2. Make sure that your jsp is located in the myprojects directory and the class file is copied under myprojects/WEB-INF/classes.
    Let me know if things still don't work
    regards,
    Abhishek.

  • Import packageless classes in a jsp : tomcat 5.0.16

    Hi all,
    I am trying to import a class, say one.class, which is stored in the /WEB-INF/classes folder of the webapplication into a jsp page. Like,
    <%@page import="one"%>
    I get the following error,
    C:\jakarta-tomcat-5.0.16\work\Catalina\localhost\test\org\apache\jsp\testing_jsp.java:7: '.' expected
    import one;
    what could the problem be? I suppose, the problem is in accessing a class which is not inside a jar.
    take care,
    Siddharth.

    Hi,
    If you are using jdk 1.4 and above, you need to have package name for classes .
    You could just give a try after removing the import statement . Perhaps the server could find the classes in your WEB-INF/classes directory. I doubt though.
    -Amol

  • How to import a class, which is not in a package?

    Hi all,
    I have the following problem:
    A class A is not in a package. In another class B, which is in a package (let's say package X) I want to use the class A. Without importing the class A, I get the error "Cannot resolve symbol".
    Using the import statement import A; gives the error ". expected".
    How can I import that class?
    Best wishes to all ...
    Heiko

    > I have the following problem:
    A class A is not in a package. In another class B,
    which is in a package (let's say package X) I want to
    use the class A. Without importing the class A, I get
    the error "Cannot resolve symbol".
    I think not putting a class in a package is a bad practice. Avoid that.

  • Importing a class from another context?

    Hi JSP techies,
    Im using RESIN and having a simple problem of figuring out how to import classes from another context, if Im using the right word.
    ie.
    My .jsp files are under $home/resin/doc/test dir. And in the jsp file, I would like to import a servlet class or a plain java class. But the servlet classes and all other classes are located under $home/resin/webapps/project/WEB-INF/classes/a/b/c
    Hence when I say
    <% page import="a.b.c.*" %>
    I get an error saying "a" not found.
    1. When I say "servlet classes are in a different CONTEXT", is that right? or is it just another directory?
    2. How can I make the jsp file import the classes from the servlets class path?
    Note: Ofcourse, when I copy the package to the
    $home/resin/doc/WEB-INF/classes dir, everything works fine. But thats simply not an efficient way to get around. Could anyone clear my doubts on this regd.?
    Thanks in advance.
    Arun

    Oh... I get it now. I'm sorry, I had you poorly misunderstood. You are trying to import servlets from another web app or servlet context. I would suggest you put servlets that are common to all web apps in the system classpath and not tie them to any particular web app. In other words create a package directory structure from the system's root directory or any where outside of any web apps and point the system classpath to the beginning of that directory structure. I have a similar thing going with Tomcat. I have a folder in my root called Java_Class which is in my classpath. I build all common utilities in this directory. So I have a com/craig/web structure that holds my AppServlet which is in package com.craig.web. This servlet is visible to all web apps via the Windows classpath. Servlets particular to an application like say an MusicOrderProcess servlet would reside in a package under the webserverhome/webapps/MusicStore/WEB-INF/classes directory where webserver home is the home directory of the webserver you are using. I've tested this across webservers as well (orionserver and Tomcat) and it works.
    From the prompt you include in your posts I am guessing that you are running on UNIX. Move your common servlets out of their respective web apps and into a common directory structure. Configure the UNIX $CLASSPATH (or is it $classpath?) environment variable to point to this sturcture and you'll be on your way!
    Post again if you have more questions!

  • Importing WebService class into Forms10g

    Hi ,
    I want to import webservice from Jdeveloper in Forms10g.I am using Jdeveloper 10.1.3.4 complaint with JDK 1.4. When I import the class in Forms10g from Jdeveloper it gave me error:
    Importing Class Proxy.classes.oracle.srtutorial.datamodel.proxy.SendServiceSoapClient...
    Exception occurred: java.lang.UnsupportedClassVersionError: Proxy/classes/oracle/srtutorial/datamodel/proxy/SendServiceSoapClient (Unsupported major.minor version 49.0)
    I figured out that this error is due to different versions of JDK used in Oracle Forms10g(JDK 1.3) and Jdeveloper 10.1.3.4(JDK 1.4). So I changed the compile properties in Jdev to 1.3.
    After changing this to 1.3 when I import the class the previous error is resolved but I get another error :
    Importing Class Proxy.classes.oracle.srtutorial.datamodel.proxy.SendServiceSoapClient...
    Exception occurred: java.lang.NoClassDefFoundError: Proxy/classes/oracle/srtutorial/datamodel/proxy/SendServiceSoapClient (wrong name: oracle/srtutorial/datamodel/proxy/SendServiceSoapClient)
    Please help how to resolve this.
    Regards,
    Noman
    Edited by: user773433 on Aug 11, 2009 4:33 AM

    Hi,
    I have tried. The problem is when I make the JAR file in Jdeveloper and Change the class path in Windows. The Jar doesnt shows up in Formgs10g when we import the class. I have tried several times by adding the path of JAR file in windows environment but still it doesnt shows up..
    Regards,
    Edited by: user773433 on Aug 12, 2009 10:54 AM

Maybe you are looking for

  • Still weird problems with CS4/My new computer

    Here is situation. Machine works very well when I´m editing HD video but soon as I start edit multi-cam: PROBLEMS! And as I watch from monitor that materia that I been edited so far, it works well, but as soon as I try to change cameras, everything s

  • Problem in using JDeveloper 10g with JHeadstart

    I am using JDeveloper 9.0.3 and jheadstart 9.0.4.5 and I would like to test jdeveloper 10g preview with JHeadstart. So, I have downloaded the JDeveloper 10g to test it with my old application. Having run the Jdeveloper for the first time, I realized

  • Creating a DVD from flash movies (flv)

    Does iDVD 6 support flash movies (flv) importing? -pom-

  • Use of transactional triggers in Forms 4.5.

    Hi All, Can any body help me in using transactional triggers? It 'll be best if anybody send me a text version (.fmt) of ttrig.fmb**, which is a demo provided by Oracle, with D2K release 1.x. This form 'll solve my purpose, since it demonstrates all

  • One Material Multiple Characteristics

    Dear All, We are a chemical industry, following is the scenerio. There is a product caustic soda of different concentrations like 33% and 50%. Its a continuous process, during in process at the end point of process we note the concentration of causti