Cannot import self-defined .java files?

Hi,
I created a MouseHandler.java file that contains a class (without main() ). and I have another appletcode.java file that needs to import it:
import MouseHandler;
I tried to javac appletcode.java and it said it couldn't find the package MouseHandler but I didn't package it in the first place.
I tried JBuilder to compile it and it too gave:
"Class required but identifier found at line 1, column 1"
How do I import my source file(if it is possible)?
Thanks.

As it stands, if the compiled .class file is in the
same directory as your program, it should run fine
without the import statement. Notice, the import is
failing, but your references to it aren't?It's in the same directory. I took out the import statement and it gave error:
class MouseHandler not found in class appletcode at line ..., column ..
PS: this code is actually from Beginning Java 2 by Wrox. Since mine couldn't work, I downloaded their code. Their code didn't contain the import statement (which should work like you said), but when I compile their code, it gave the same error as above too.
Assuming that code and directory is correct, is there any other possible reasons why this is happening?
Thank you

Similar Messages

  • Import statement in .java files and .jsp files

    Guys I have few mysteries about this import statement.
    Please correct me if I am wrong.
    1)Suppose if I have a folder c:\SourceFolder it has one.java and two.java files.If I compile one.java then one.class files is created in c:\ClassFolder .Now two.java uses one of the method of one.java,and without using import statement I am able to compile two.java, and two.class file is created in c:\ClassFolder.I assume that the path of one.class was taken from the CLASSPATH environment variable,hence I there was no need for import statement .........am i right ?
    BUT... in My.jsp,which is in C:\JspFolder, if I want to use one.class,then I have to specifically import the class I want to use.That is i have to say
    <%@page import="one"%>
    and since the classpath is C:\ClassFolder ,it finds one.class in the C:\ClassFolder.(Note that My.class is created in a folder different from c:\ClassFolder )
    But I am wondering why was there no need for me to import one.class in two.java.
    (Note I am using JDeveloper and Apache server)
    Please help.
    In this case the pSo I am wondering in JSP why it doesn't take the class I am looking for from the classpath .
    Help.

    You have to understand Java scoping rules. In the 1st scenario with the two Java files I am guessing neither one of them begins with a package statement. This means that they belong to the default package. When you compile the compiler uses the classpath to resolve method calls looking in the default package since there was no import statement specified in two.java. JSP is a little different. Now I just read this here in these forums a couple of days ago. Since the classfiles generated from the JSP files are not in the CLASSPATH they are loaded by a different classloader. This is why you have to import all references to all classes in the default package.

  • Import statement in .java files and .jsp files ..correction

    Guys I have few mysteries about this import statement.
    Please correct me if I am wrong.
    1)Suppose if I have a folder c:\SourceFolder it has one.java and two.java files.If I compile one.java then one.class files is created in c:\ClassFolder .Now two.java uses one of the method of one.java,and without using import statement in two.java I am able to compile two.java, and two.class file is created in c:\ClassFolder.I assume that the path of one.class was taken from the CLASSPATH environment variable,hence I there was no need for import statement .........am i right ?
    BUT... in My.jsp,which is in C:\JspFolder, if I want to use one.class,then I have to specifically import one.class in My.jsp .That is i have to say
    <%@page import="one"%>
    in My.jsp.
    and since the classpath is C:\ClassFolder ,it finds one.class in the C:\ClassFolder and MyJsp is compiled sucessfully.(Note that My.class is created in a folder different from c:\ClassFolder )
    But I am wondering why was there no need for me to import one.class in two.java.
    (Note I am using JDeveloper and Apache server)
    Please help.

    It has to do with packages. Most java classes are in a package, the name of which must conform to its place on the filesystem relative to the classpath. By that I mean that if you have com.mystuff.One.java, it must be in a folder com/mystuff where com is located somewhere in the classpath.
    What you've done is a little different. I'm assuming a couple of things:
    1. you have no package declaration at the top of one.java or two.java
    2. you have the current directory "." in your classpath.
    Java has the concept of the "default package", which covers classes without a declared package, and in your case is the current directory.
    So when you're in c:\sourcefolder and run the compiler, then "."="c:\sourcefolder", and that directory is part of the default package. No import statements are necessary for classes that are in the same package. This is why two.java can call methods in one.java without an import statement.
    When you run your jsp, the "current directory" part of your classpath is not c:\sourcefolder, but some other value (probably the directory you start your jsp engine from) You will have to import all non-java-library classes because the jsp itself becomes a java class, with a package that is determined by the jsp engine.

  • 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.
    Thanks

    In 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.

  • Cannot import sony arw raw files into lightroom 5

    How can I import sony arw raw files to lightroom 5.  On Import I cannot convert them to dng.

    What camera?
    What version of Lightroom?
    What is the exact complete word-for-word verbatim error message?
    What exactly do you see on your screen anyway when this is happening? Describe in detail.

  • Cannot import Mark III RAW files w LR4

    I just upgraded to LR4 but still cannot import my Canon 5D Mark III raw files. Any suggestions??

    You'll need 4.1 or later.  Check for updates.

  • Cannot import movie or audio files. Can drag jpg files into imovie though.

    Hi, I recently re-installed 10.3.9 (about 2 days ago).
    imovie was working just fine until i opened it this morning only to find I couldn't import anything other than picture files.
    I get this message when i try.
    "can't open file (insert file name here) skipping it and continuing"
    When i re-open imovie i get a message telling me
    "there are x amount of files that don't belong in this project would you like to move to trash"
    I'm given the option to leave files alone or trash unused files.
    HELP!
    I got this response
    When you reinstalled 10.3.9 did you repair permissions before and after, as well as repairing your hard disk with Disk Utility on your Install Disk?
    After which I tried doing what was suggested but still have the same problem. I even tried using pacifist.
    Is there an newer version of imovie available for download?

    Sorry, I don't go back that far!
    This is the iMovie 5 forum. You might get a more knowledgeable response if you post in the iMovie 4 and earlier forum:
    http://discussions.apple.com/forum.jspa?forumID=855

  • Cannot import Canon 500D .MOV files into Lightroom 4.1

    I've seen a few problems on here about similar issues.
    I've imported .mov files before, but a perfectly valid (short, circa 10 seconds) .MOV clip just will not preview or import into Lightroom 4.1 on my Win7 x64 system.
    The movie will play fine directly from the card, but just won't import!
    Any ideas, chaps?

    I've seen a few problems on here about similar issues.
    I've imported .mov files before, but a perfectly valid (short, circa 10 seconds) .MOV clip just will not preview or import into Lightroom 4.1 on my Win7 x64 system.
    The movie will play fine directly from the card, but just won't import!
    Any ideas, chaps?

  • Cannot import or open CS6 files in CC

    I am aware and understand that many NLE systems are not backwards compatible.
    Forward compatible is another story in most cases.
    I have and love Adobe Premiere CS6.  I had to reformat ther other day, went to look for Adobe Premiere Pro CS6 to download and could not find it.
    Adobe CC is blasted everywhere on the Adobe site.
    I decided to just do the monthly deal and upgrade as I just want to get back to work.
    I cannot open or import any of the old projects I have from CS6.
    I have tried deactivating and reactiving as suggested.  I have tried multiple hard drives and multiple projects.
    This is very frustrating.  I am losing time and money.
    I would love to see a helpful answer from Adobe. 
    I am on 10.7.5  My Premiere CC is up to date.
    Please help,
    Nicholas

    Thanks for the swift response Joe Bloe!
    It appears I can't download the app in English...
    I am trying anyways to see if they just didn't explain it well.
    I have tried your suggestion.
    You might try creating a new Project, then importing
    the CS6 Project into the new, empty Project.
    I don't want to, but I am trying EDL and XML exports off my laptop which still has CS6 thankfully.
    Thank you again Joe Bloe

  • I cannot import windows media player files into itunes.

    Can anyone recommend a way to convert wm files so I can import into itunes?
    Thanks
    Alexi

    You need to use a tool such as Switch on the Mac; iTunes on Windows will handle the conversion itself. The Windows version of iTunes won't convert protected WMA files, and no Mac software will.
    (46691)

  • Cannot import NEX-6 raw file (ARW)

    I downloaded a Sony NEX-6 raw file (ARW) from dpreview to check out the image quality. But, Aperture does not "see" the file at all.
    I have the latest Aperture 3.5.1 with Digital Camera Raw 5.04 (and Maverick) – and I have a Sony A700, with no problem importing raw files from that. According to Aperture support page there "should" be no problem with the NEX-6 camera.
    Anyone know how to solve this?
    Best regards, Magnus

    So I tried with draging the image to the Aperture icon in the Dock – and that worked!   And, if I first uploaded the file to Dropbox, and then downloaded it again – then Aperture "can see" the file and I can import the image the usual way
    Great voodoo, Magnus - did you swing a chicken over the mac as well? I am glad you could solve the problem.
    Trying an explanation of what might have happenend:
    Aperture probably will have hidden the image in the Import panel, because it erraniously recognized it as duplicate or an excluded file type because of a problematic file signature. Dragging to the Dock icon is forcing the import, even of duplicates or excluded file types.
    And adding to DropBox and then downloading again may change file attributes. DropBox is syncing the files with the server and creating new copies. This may change the file signatures.
    Added:  There is one thing, that is a bit disconcerting about the solution you now are having.  If you have to "convert" your raws by sending them to DropBox to fix the file signatures, or circumvent the Import panel by dragging to the Dock icon, there may be a problem with your "Import Presets.plist" or other cached preference files.
    If the problem happens again, quit Aperture and trash this file "/Users/your shourt user name/Library/Application Support/Aperture/Import Presets.plist". Then reboot the system.

  • I cannot import 5.1 WAV files into iTunes

    Hello
    I'm running iTunes 11.1.5 (5) 64 bit on OSX 10.9.2. I'm trying to import some wav files into iTunes, they are about 6-11 minutes long each, they have 5.1 (6 total) channels, 16 bit depth and are sampled at 48,000 kHz. I can run them in QuickTime Player 10.3 (727.3) without any problems, but iTunes will not run them. This stil happens if I try to import the same files when they are in Apple Lossless format as well. I have several other surround sound files sourced from other stuff and they wil not import either, but they still run in Quicktime Player just fine. I don't have any pluging installed for iTunes or QuickTime Player. Does iTunes just not support surround sound audio, or is there something wrong with the files that I'm trying to import?

    Hi Michael,
    I bounced a PCM 5.1 WAV Audio File from Logic Pro X, This File alredy plays 5.1 surround from desktop just with the space bar preview and also with QuickTime ok? But Itunes 11 doesn´t import PCM 5.1 (multi) Wav audio files as you know, so I Knew that in the Itunes 11 for the movies tracks the 5.1 surround audio is automatic.See this link below
    http://support.apple.com/kb/ht4072 -
    What I did?
    I just imported my audio file to Apple COMPRRESSOR, and choose the H.264 output format and I changed from .MOV to .MP4 (This one Itunes import with multi audio 5.1)
    and also select 48 Khz and 720 Kbps. After encoding my audio file from ( 226 Mb) PCM 5.1 Wav about 4.20'  went to a AAC 6 channes 48 Khz / 720 Kbps  .MP4 file with 24 Mb size. Itunes import withou problem and played 5.1 surround as I wish.
    I hope you understood my explanation,
    Regards
    Paulo

  • Itunes 7.2 cannot import music folders or files!

    After the updates, I've installed itunes 7.2. However, when I start to import music folders or music files [mp3 and other formats], it doesn't work or try to import the source to the library! It also happens to my CDs and my backup CDs!
    What is going on apple?

    I am running iTunes version 7.7.1.11 at the moment. You can verify that you are indeed using the most up to date version of the program by going to Help > About iTunes.
    When you say that adding files to the library is not working, what do you mean? Is it not recognizing the files, is the application failing to convert the files other than MP3/AAC to a playable format?
    Also, iTunes does not move the original media file to where it is storing the library. By default, iTunes leaves the file where it is and makes a reference to it in its library file. You can go into the Preferences dialog box, select the Advanced tab, and select the checkbox next to "Copy files to iTunes Music folder when adding to library" and click the OK button in order to have iTunes only manipulate files literally stored in its library.
    Does that address your concerns?

  • Cannot import WSDL to JAVA JAX-RPC (using WSCOMPILE)

    I exported a WSDL-file (i.e. for RFC_PING) via the BSP WebServiceBrowser (WAS 6.20). For generating the interface i have to start the wscompile-tool of JAX-RPC (right ?). But wscompile answers with an error:
    unerwartetes Element "definitions" in Konfigur
    ationsdatei (Zeile 1)
    Are the WSDL-files not compatible ? How I have to work with the WSDL ?

    Oops, i used a wrong configfile for the wscompile tool. It's all right now.

  • Cannot compile java file after ..

    i installed java sdk 1.4
    uninstalled java 1.2 & java 1.3.1
    --after that i was not able to compile or run java file
    reinstalled java 1.3.1 and 1.2
    --now able to run previously compiled java file
    --cannot compile a new java file
    any help

    It would be helpful if you would exactly tell us what error message you get instead of just saying "I can't compile or run anything anymore".
    Things to think of: Did you add the bin directory of the JDK to your path? Is the classpath set correctly?
    Installation notes
    http://java.sun.com/j2se/1.4/install-windows.html
    Setting the class path
    http://java.sun.com/j2se/1.4/docs/tooldocs/win32/classpath.html
    Java 2 SDK Readme
    http://java.sun.com/j2se/1.4/README.html
    Jesper

Maybe you are looking for

  • Concept of variable

    Hi, I have a scenario wherein i ge the table name from a select query in a variable and then i have to do another select query on this new table.  But because this table name is stored in variable, i'm not gettign how to do a  select query on it. Reg

  • Plug in says to update Adobe Acrobat, but I have newest version

    I have updated and it has verified when I retried to update but yet the plugin still tells me to update as there is a vulnerability. Should I uninstall Firefox and reinstall?

  • "Using a CIN to Create an Array of Strings in LabVIEW" example crashes LV on Linux

    Tried to utilize this NI example: "Using a CIN to Create an Array of Strings in LabVIEW" (http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B4B282BE7EF907C8E034080020E74861&p_node=&p_source=External) Compiles OK with the makefile made

  • Static only out of right side of hd 555 heatset? sol

    ?i got a senheiser hd555 headset and a hi fi extreme gamer card. and i seem to be getting a faint static sound out of the right can only.. i've read alot on here about the static problems.. does anyone else have it just out of one side of there heads

  • Nikon D5000 HD 720p 24fps sequence settings

    Hi. Does anyone know what my setup/ sequence settings need to be to edit HD footage I shot with a Nikon DSLR D5000? I've converted the .avi clips to .mov using NikoPro. All the settings I've tried want me to render the shots as soon as i drop them on