Cannot import classes
I have one class calling another, like this:
import CloseWindowListener;
import DatabaseSearchControls;
import java.awt.event.*;
public class DatabaseSearch {
public static void main (String[] args) {
DatabaseSearchControls frame = new DatabaseSearchControls();
frame.addWindowListener ( new CloseWindowListener() );
frame.show();
I get these errors when I compile DatabaseSearch:
C:\Documents and Settings\Korbel\My Documents\benmay\DatabaseSearch.java:9: '.' expected
import CloseWindowListener;
^
C:\Documents and Settings\Korbel\My Documents\benmay\DatabaseSearch.java:10: '.' expected
import DatabaseSearchControls;
The other 2 files complied correctly and are in the same directory. Anyone ever seen this and know what I am doing wrong?
Thank you!
Are you compiling with version 1.4? If so, it is now invalid to import classes that don't belong to a package. It is not necessary to do so anyway, so just remove the import statements. Better yet, follow the Java standard and put each class you write into a named package, using the package statement.
Similar Messages
-
Cannot import classes such as ObjectFile, Scene, ...
Hi Java'ers,
I wanted to load some ObjectFile into my Java program but I have no idea what's wrong about my method.
I need do this so I can load an objectfile (.obj) into my program:
import com.sun.j3d.loaders.objectfile.ObjectFile;
Eclipse says that it doesn't exists. But, when I import this:
import com.sun.j3d.loaders.objectfile.*;
This line is good, Eclipse says that this exists. So the directory is good but he can't find the classes in the directory's.
I imported this jar-files in my project:
- j3dcore.jar
- j3dutils.jar
- vecmath.jar
My steps for importing the jar-files
import -> Archive File -> Browse... -> (jar-file)
Can you programmers help me to get this working?
Thank youuse the flash help files. for example, this is the explanation of the intrinsic keyword from the help files:
"Allows compile-time type checking of previously defined classes. Flash uses intrinsic class declarations to enable compile-time type checking of built-in classes such as Array, Object, and String. This keyword indicates to the compiler that no function implementation is required, and that no bytecode should be generated for it.
The intrinsic keyword can also be used with variable and function declarations. Flash uses this keyword to enable compile-time type checking for global functions and properties.
The intrinsic keyword was created specifically to enable compile-time type checking for built-in classes and objects, and global variables and functions. This keyword was not meant for general purpose use, but may be of some value to developers seeking to enable compile-time type checking with previously defined classes, especially if the classes are defined using ActionScript 1.0.
This keyword is supported only when used in external script files, not in scripts written in the Actions panel." -
Cannot import custom made java class
Hello
I wrote a java class say (Money.java) which compiled fine. When I was importing it to another class (Account.java), the folowing error message appears:
Account.java.1:'.' expected
import Money;(an errow pointing to ";")
I dont think the code is wrong, because when I cut and attach the Money class code to the front of the Account class it compiled successfully.... I am confused! I wrote the import command according to the text book as follows:
import Money;
public class Account
By the way, both the Money and Account classes are saved in the save folder... How come it wont let me import...
Looking forward for an early reply.
ThanksIn older versions of Java, it was possible to import classes from the default package using a statement like:
import Money;
This feature has been removed from Java as of version 1.5. You cannot import classes from the default package.
Note that if your other code (Account.java) is also in the default package, you do not need to import the class Money. Just remove the import statement.
If class Account is in a different package and you want to use class Money, then the only option you have is to put class Money in another package than the default (unnamed) package. -
Hi , i have created a class called cookiecheck and have placed it in the / web directory of my tomcate context and i would like to import it. how should my import command look. at this moment it looks like this, import cookiecheck; ,but this does not work ,please could you tell me what i am doing wrong.
but when i upgraded one of the jsp tries to import a
class (that does not have a package)
eg: import site
complains that there is no site.*
any helpThat's the key. Once again, (since Java 1.4) you cannot import classes which do not belong to a package. Creating classes with no package has always been discouraged and since 1.4 that discouragement is even stronger. Refactor. -
Cannot import AppModuleImpl class
Hi experts,
I'm developing Jdeveloper 11.1.2.2.0
Suddenly I got this error.
I had created Manage bean and import pakagename.AppModuleImpl and few other Impl classes there.
Suddenly it was prompted error that ,cannot import AppModuleImpl class.
I was wonder about this error because it worked fine before.
Could u pls advise me to solve this problem.
CharithHi,
what you try to do is accomplished by creating a dependency between the modle and the viewController project (see view controller project properties). As mentioned in the previous post, crossing boundaries between the model layer and the view controller layer is not good practices. If you need to access an AM method, expose it on the client interface and create a method binding so it can be accessed from and through the ADF binding layer.
Frank -
I was reading the tutorial on importing class's. This is what
I read
Importing classes
To reference a class in another script, you must prefix the
class name with the class's package path. The combination of a
class's name and its package path is the class's fully qualified
class name. If a class resides in a top-level classpath
directory--not in a subdirectory in the classpath directory--then
its fully qualified class name is its class name.
To specify package paths, use dot (.) notation to separate
package directory names. Package paths are hierarchical, where each
dot represents a nested directory. For example, suppose you create
a class named Data that resides in a com/xyzzycorporation/ package
in your classpath. To create an instance of that class, you could
specify the fully qualified class name, as shown in the following
example:
var dataInstance = new com.xyzzycorporation.Data();
My Question is about com/xyzzycorporation/ . would the full
class parth be c:/com/xyzzycorporation/ . Why do they never state
the drive letter when teaching about directories.Because there is no need. you don't need to reference the
drive letter.
Here's the basic jist of what they are saying....
Single Class File...
If you create your own custom class and want to use it in
your flash file, save it into the same directory as the fla file
and call the classes constructor. By default flash will look inside
the folder where the fla resides in for the class files if it
cannot find it inside the default directory.
Multiple Class Files - 1 Project (often referred to as
packages)
Use your qualified domain name but backwards.....
my domain is www.sd-dezign.com so if I was going to include a
package of utility class files in my document I would do the
following
Create a folder in the same folder with my fla name it com
and inside that a folder called sddezign and inside that utils and
all my as files would be in there...the folder structure might look
like this....
myfile.fla
com
>sddezign
>>utils
>>>box.as
>>>circle.as
To call the constructor for each class, I have two options.
The first which is by far the easiest looks like this
In whatever frame you need to call that class constructor
include "com.sddezign.utils.*";
var myBox:Box = new Box();
The second method requires more typing and can get tedious
var myBox = new com.sddezign.utils.Box();
Hope this helps you a bit better. -
Inner class vs. imported class
Hi everyone,
I have entitiy beans created for a client's web app I'd like to use in the
web service using WebLogic Workshop 7.0. Say the classes are imported like
this in the services:
import com.hoike.clientname.ap.bean.Invoice
import com.hoike.clientname.ap.bean.Vendor
Instances of these classes are used in callback methods and some of the
service methods.
When I generate the CTRL file, it actually adds those imported classes as
inner class of the service defined.
The problem is that when I try to used these services from another service,
I cannot use the imported classes (as Invoice or Vendor), but instead I have
to use the inner class (InvoiceService.Invoice or VendorService.Vendor)
Does WebLogic Workshop 7.0 only allow you to use inner classes? Is there a
way to use custom classes as method parameters?
Thanks in advance!
Makotohow do you declare your inner class?
Is it (public)
public static class MyInnerClassor (private)
private static class MyInnerClassor (package)
static class MyInnerClassor (protected)
protected static class MyInnerClassTry to change the way you declare the inner class. Use protected or package or public instead. -
I have a class called Tools that resides in the WEB-INF/classes folder. It is a very general class with frequently used methods and thus is not in a package. My problem is this: I cannot import it in my .java class files. I can, however, import it in a JSP file. The error also goes away if I put the class in a package and declare the import accordingly (I do not want to do this, however, as other pages within the application already reference it as is). In the java class, it just throws the error:
login/UserAuthenticate.java [18:1] '.' expected
import Tools;
UserAuthenticate is the name of the bean I am trying to import it in. I have tried many different ways of declaring the import, but to no avail. My apps are running on Tomcat 4.0.6. If anybody has any ideas, they would be greatly appreciated.
--NicoleSounds like it's in your Tomcat (or whatever container you're using) classpath, but not your normal Java classpath. Since you're compiling your source yourself, javac needs to know where it is.
-
Hello,
I'm playing with JDeveloper and Java for the first time and am running into some problems. My sample code is importing a bunch of classes, and when I compile my code I'm getting a bunch of errors saying -
Error(19,30): cannot access class oracle.reports.server.Security; file oracle\reports\server\Security.class not found
Error(23,31): cannot access class oracle.reports.utility.Utility; file oracle\reports\utility\Utility.class not found
I'm a little confused as to what I need. Is Oracle.reports... a special set of classes that I need to download from somewhere? I found this sample code at http://www.oracle.com/technology/products/reports/apis/plugSecurity/resources.html
Any guidance would be helpful!! TIA!
My code -
package oracle.reports.plugin.security.xml;
import oracle.reports.server.Security;
import oracle.reports.server.Job;
import oracle.reports.RWException;
import oracle.reports.utility.Utility;
import oracle.reports.utility.CommandParser;
import java.util.Properties;
import java.sql.Time;
import java.io.FileReader;
import java.io.File;
import java.io.StringReader;
import java.io.FileNotFoundException;
import java.io.IOException;
// imports required for Oracle XML Parsers
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.NamedNodeMap;
import org.xml.sax.SAXException;
import oracle.xml.parser.v2.DOMParser;
import oracle.xml.parser.v2.XMLParseException;
import oracle.xml.parser.v2.XMLConstants;
import oracle.xml.parser.v2.XMLDocument;You need a jar file with these classes (the Oracle Reports classes) then you can add this jar to your project properties under libraries - and then your compile should work.
I'm not sure what are these classes but my guess will be that you'll find it in an Oracle Reports install - might be worth asking this on the reports forum as well. -
Error when I import classes using directive JSP page
Hi all!
I have installed JDeveloper 11g (11.1.1.3.0)
My applications are located in the C:\dir (JDEV_USER_DIR = C:\dir)
I Created application "Appliation1". In it i created 2 projects (Project1, in it beans session entity and other java classes; Project2, in it JSP).
I want import classes from Project1 to Project2 using next directive:
<%@ page contentType="text/html;charset=windows-1252"
import="project1.*"%>
so in Project properties of Project2 set the way to classes in Project1.
When i run JSP an error occurred:
Error(4,9): The import project1 cannot be resolved
Maybe i'm not set correctly the way to the classes
Thanks in advance.angelr, thanks, it helped me)
In jdeveloper 10g i set address in Project Properties->Libraries and Classpath->Add JAR/Directory;
and set the way to my classes;
and it worked.
in the 11 version seems different -
Dear Forum,
we are developing portlets for Portal 3.0.9.8. We use the default JPDK version, that comes with the standalone Oracle OC4J 9.0.4 bundled with PDK.
We want to improve our portlet by check the userid of the portal user. Therefore, we want to use oracle.portal.provider.v2.ProviderUser.getUser().getName()
in a JSP.
First - even before the method call - we included
<%@ page import="oracle.portal.provider.v2.http.ServletProviderUser" %>
But even this 1 statement gives in JDeveloper 9.0.4 with the libs pdkjava and ptlshare from the OC4J the following error:
Error: cannot access class oracle.security.jazn.realm.RealmUser; file oracle\security\jazn\realm\RealmUser.class not found
What is wrong here? What missing library we must include?
Thank You in advanceProblem solved. Need to include jazn.jar in project's lib-paths.
-
Cannot access class oracle.sql.BLOB;
Hi,
I am trying to save a .tif file into Oracle database. When I run the program in JDeveloper I get the following errors:
Error(9,19): cannot access class oracle.sql.BLOB; file oracle\sql\BLOB.class not found
Error(59,29): class BLOB not found in class mypackage1.ImageUpload
package mypackage1;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.*;
import java.util.Properties;
import oracle.sql.BLOB;
Blob imgblob = rs.getBlob(1);
OutputStream blobos = ((BLOB) imgblob).getBinaryOutputStream();
...................Any help is appreciated. ThanksWhat package do I need to include in my classpath for
this. ThanksWhy don't you inspect your JAR files? Do you have WinZip? Open them with it and find the class. -
Cannot find class: Exception??
Hi
The compiler claims it cannot find class FileNotFoundException or any other exception in my Main. Any packages I import has no problem. My structure:
java \ myMain \ Main.java
java \ com \ myName \ packages //no, the space is just there as visual help:)
Use javac -classpath java\ @compile.file
...where compile.file is a txt file giving the paths and filenames to all files I include.
This is first time I use the -classpath parameter, but I believed java.lang always was included. What Am I doing wrong.
regards
JTYou should review the tool documentation for the javac command and its use of classpath.
Your problem appears to be due to the way you defined classpath, "-classpath java\". While you don't provide enough information to conclusively say what it should be, I'm guessing it should also include java\myMain\ - assuming that you're issuing the javac command from the parent of the \java\ directory, as your command example indicates.
Here is a clip about its use of the classpath.
"When compiling a source file, the compiler often needs information about a type whose definition did not appear in the source files given on the command line. The compiler needs type information for every class or interface used, extended, or implemented in the source file. This includes classes and interfaces not explicitly mentioned in the source file but which provide information through inheritance.
For example, when you subclass java.applet.Applet, you are also using Applet's ancestor classes: java.awt.Panel, java.awt.Container, java.awt.Component, and java.lang.Object.
When the compiler needs type information, it looks for a source file or class file which defines the type. The compiler searches for class files first in the bootstrap and extension classes, then in the user class path (which by default is the current directory). The user class path is defined by setting the CLASSPATH environment variable or by using the -classpath command line option. (For details, see Setting the Class Path).
If you set the -sourcepath option, the compiler searches the indicated path for source files; otherwise the compiler searches the user class path for both class files and source files." -
Cannot create class in system package
Hello,
I wrote a J2ME game for nokia S40 phones. It compiles without any errors, but when I'm trying to run in on the Nokia 7210 phone emulator I receive the following message:
Cannot create class in system package.
Howerver running on the Nokia 6230 phone emulator is ok.
I have obfuscated my applet as I read in previous topics, but still it does not work.
Can anyone help me?
Thanks,
Alexander.You get that error when you try to reference a class that is part of the MIDP framework but isn't installed on the phone.
The 7210 doesn't support MMAPI or WMA or MIDP 2.0, while the 6230 does, so check that you don't have any references (even an import statement), to classes from those packages (like the javax.microedition.media.*, javax.microedition.lcdui.game.*,javax.wireless.messaging.*, etc. packages hierarchies).
shmoove -
Cannot create class in system package while Using Sprite class
Hi i developed a game using Sprite class & imported
javax.microedition.lcdui.game.*; package. But when i tried to build this project it gave me "Cannot create class in system package" error. Worst thing is that now again if i build, then it displays error "package javax.microedition.lcdui.game.*; does not exist" . Pls help meFirst exception means that you tried to create a class with the package name equaling one from the predefined libraries in midp/cldc.
For your second error, add all the jars you are using into the project's classpath.
Mihai
Maybe you are looking for
-
Sales analysis report- showing & totaling both Invoices & Credit memos on o
I have written a Several sales analysis reports based on INV1 tables and RIN1 tables, (Invoice lines and Credit memo lines) for SAP B1 using crystal. I would like the data from both the invoices & the credit memo to list & total on the same report. B
-
What is the best way to delete dynamically-generated symbols from another symbol?
in the onClick handler for 1 symbol, I have: var sandwhichQty1 = sym.createChildSymbol("sandQty1", "Stage"); another symbol inside sandQty1 has the onClick method: this.deleteSymbol(); which works fine, deleting sandQty1. I'd like to delete it, and o
-
Autosave and image problems in Pages 5
I opened a doc from previous Pages version in new Pages 5 and got repeated Autosave errors. They said the file could not be autosaved as it was created by another application and the location could not be found. I then I saved it as a new document w
-
Dear All In our client place we procuring Material against network and WBS Element.When i am doing PO for network the system throws error when it exceeded the budget.But when i am Procurement material WBS Element (Reservation+PR for WBS Element) Proj
-
Can't send files from/to MBP Mavericks/ipad
Hi, I am unable to send files from my mac book pro 10.9 to the ipad4 & vice versa. They are connected on bluetooth but when I press send I get the message "this devise does not have the necessary services". thanks HH