HELP- Can't Import My Classes

I've just recently gotten into Java development and have been able to make very basic programs?if you could call them that. To basically introduce myself to Java programming, I thought I'd create a simple tab-based text editor (think Microsoft Notepad with the ability to edit multiple files at once). I've created a basic menu bar class file, a tab-based editor pane/window class file, but am having trouble with the class file I'm using to incorporate the two together. I've had Steven Haines' Java 2 from Scratch at-hand for a week or two now (up to date, no; useful to a degree, yes) and have designed the application with a structure similar to the app in the book.
The structure of the main class file:
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import menuBar;
import jPad;
public class jNotepad extends JFrame implements ActionListener
menuBar menu=new menuBar();
jPad jNote=new jPad();
public jNotepad()
super("JNotepad v1.0");
setJMenuBar(menu);
menu.addActionListener(this);
jNote=new jPad();
getContentPane().add(jNote,BorderLayout.CENTER);
setSize(600,300);
setVisible(true);
addWindowListener
new WindowAdapter()
public void windowClosing(WindowEvent closer)
System.exit(0);
public void actionPerformed(ActionEvent performed)
JMenuItem item=(JMenuItem)performed.getSource();
if(item==menu.fNew)
System.out.println("File->New");
else if(item==menu.fOpen)
System.out.println("File->Open...");
else if(item==menu.fClose)
System.out.println("File->Close");
else if(item==menu.fCloseAll)
System.out.println("File->Close All");
else if(item==menu.fSave)
System.out.println("File->Save");
else if(item==menu.fSaveAs)
System.out.println("File->Save As...");
else if(item==menu.fSaveAll)
System.out.println("File->Save All");
else if(item==menu.fPrint)
System.out.println("File->Print");
else if(item==menu.fExit)
System.out.println("File->Exit");
else if(item==menu.eCut)
System.out.println("Edit->Cut");
else if(item==menu.eCopy)
System.out.println("Edit->Copy");
else if(item==menu.ePaste)
System.out.println("Edit->Paste");
else if(item==menu.eDelete)
System.out.println("Edit->Delete");
else if(item==menu.hContents)
System.out.println("Help->Contents");
else if(item==menu.hAbout)
System.out.println("Help->About");
public static void main(String[] args)
jNotepad jNotepadv10=new jNotepad();
For some reason or another, whenever I try to compile the java file into a class file, it gives me an error stating that I need periods after the "import menuBar" and "import jPad." Then if I add the periods and recompile, it says I need identifiers after the periods, so I add asterisk identifier masks and recompile again just to be told the packages menuBar and jPad do not exist. I can't go any further with my program until I resolve this issue. Any assistance would be appreciated.

use package For example pjb is my initals. I like to have top package of all my programs.
At the top of the java file of NotePad.java, should be
package pjb.apps.NotePad;Make sure that java file and compiled class file is in that directory
\pjb\apps\NotePad.java
\pjb\apps\NotePad.class
\pjb\apps\Calculator.class
Ok Now with your imports do the following. A made up JOS program requires apps to use.
\pjb\os\jos.java
\pjb\os\jos.class
In the jos.java i have
import pjb.apps.*;
...jos coding
public void showAppCalculator() {
  Calculator josCalculator = new Calculator();
  josCalculator.show();
...jos codingAnother example is I just want NotePad imported
import pjb.apps.NotePad;
...jos coding
public void showAppNotePad() {
  NotePadjosNotePad = new NotePad();
  josCalculator.show();
...jos codingor make sure the the classes are all in the same directory as your application program.
See http://java.sun.com/docs/books/tutorial/java/interpack/index.html
for more details about packages.
Hope it helps :)

Similar Messages

  • How can I import a class in my program?

    In my program I want to use a class named "WordExtractor" that resides in a jar file named "poi-3.0.1-FINAL-20070705.jar".
    This jar file is stored on my computer under:
    D:\java_projects\Word Reader\poi-bin-3.0.1-FINAL-20070705\poi-3.0.1-FINAL\poi-3.0.1-FINAL-20070705.jar
    How can I import this class WordExtractor into my program?
    import ????????? ;

    In my program I want to use a class named
    "WordExtractor" that resides in a jar file named
    "poi-3.0.1-FINAL-20070705.jar".
    This jar file is stored on my computer under:
    D:\java_projects\Word
    Reader\poi-bin-3.0.1-FINAL-20070705\poi-3.0.1-FINAL\po
    i-3.0.1-FINAL-20070705.jar
    How can I import this class WordExtractor into my
    program?
    import ????????? ;After you add this jar file to the lib , you can use a tools(rar extracter tools) to extract "poi-3.0.1-FINAL-20070705.jar" file and find the position of that class "WordExtractor" .
    write "import XXXX.WordExtractor"into your program,"XXXX" is the position that you have found.

  • Only a type can be imported. package.Class resolves to a package

    Hi,
    I made a class for database connection named ConnectionClass.class.
    The JSPs in public_html directory working fine with import and session variables.
    but JSPs under public_html/subdirectory are unable to import this Class and also unable to access session variables.
    I have deploy this class under public_html/WEB-INF/classes/ directory.
    and also in a jar file vidyabharti.jar under public_html/WEB-INF/lib directory
    I am importing it in JSPs like
    <%@ page import="vidyabharti.ConnectionClass, java.sql.*" %>
    but i am getting following error
    An error occurred at line: 6 in the generated java file
    Only a type can be imported. vidyabharti.ConnectionClass resolves to a package
    An error occurred at line: 110 in the jsp file: /welcome.jsp
    ConnectionClass cannot be resolved to a type
    109: <%
    110: ConnectionClass cs=null;
    An error occurred at line: 115 in the jsp file: /welcome.jsp
    ConnectionClass cannot be resolved to a type
    cs=new ConnectionClass();
    i am using Tomcat 5.5.28.
    please help me.

    Hello,
    It's a possible issue whith the JDT compiler version of your tomcat distribution.
    You know that jasper is the engine that transform jsp to classes and to achive this goal uses a jdt compiler or the ant task javac compiler.
    First check that the JDT compiler class is present in the trace of the exception you have.
    If this is the case follow the steps of the tomcat documentation in order to use the ant compiler.
    http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html
    Apache Ant, which was used in previous Tomcat releases, can be used instead instead of the new compiler by simply removing the common/lib/jasper-compiler-jdt.jar file, and placing the ant.jar file from the latest Ant distribution in the common/lib folder. If you do this, you also need to use the "javac" argument to catalina.sh.
    If you check the code of the tomcat compilation context seems that you can do the same, without removing any file, by setting the compile parameter of the JspServlet to an arbitrary value diferent from null.
    Try this other alternative by editing the file %TOMCAT_HOME%\conf\web.xml
    and set the compiler attribute as follow
        <servlet>
            <servlet-name>jsp</servlet-name>
            <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
            <init-param>
                <param-name>fork</param-name>
                <param-value>false</param-value>
            </init-param>
            <init-param>
                <param-name>xpoweredBy</param-name>
                <param-value>false</param-value>
            </init-param>
            <init-param>
                <param-name>compiler</param-name>
                <param-value>Ant</param-value>
            </init-param>
            <load-on-startup>3</load-on-startup>
        </servlet>If this works for your problem we can check the jdt code and perhaps make a patch.
    Best reggards,

  • Need Help - Can't Import ANY Images into LR4.4 Since OS Upgrade

    I can't import ANY images to LR 4.4 since upgrading my Mac OS to Mountain Lion 10.8.3 this past week. I downloaded LR5 Beta and all works well. I deleted LR5 Beta to see if it was conflicting with LR4.4 somehow and rebooted. Still no change. I can't import from my card reader (that says it can't even read the files) or from a location on my hard drive. I am beyond lost and frustrated.
    The error message for importing is "Could not copy a file to requested location."
    I need ideas. I am afraid to deleted and reinstall as I don't want to lose all my folders within. I looked all over the web and can't figure it out.
    If you need any other info, please let me know. I am hopeful that someone can help me.

    I added LR5 again and that works perfectly, but LR4 is still not working properly. I opened the preferences and catalog settings to compare...and they all look the same. I am beyond baffled. I don't plan on dropping more money for LR5, so I need LR4 to get back to working properly.

  • Can't import custom class!

    I have no idea why as3 is so stupid but it is and I have to
    deal with it. Basically, I creatd a Server.as file with the Server
    class but I can't import it into my .fla! Both are in the same
    folder and when I change properties to use AS2 it works! But when
    I'm doing it in as3 it doesn't work...

    you don't need to use a directory structure for your files'
    location, but you need to use the package designation in your class
    definitions.
    for example, if your Server class file is in the same
    directory with your fla, you can use:

  • HELP Can't import my photos

    I purchased an external hard drive not too long ago as my hard drive was reaching capacity. I dumped all of my Iphoto library onto it to free up as much aspace as possible. I upgraded to iLife 06 on my computer shortly thereafter. After freeing up an even more significant amount of space, I purchased aperture with intentions of reimporting my images. Direcly trying to import from the external brought up a message saying it wasn't possible as they were from the wrong version of iPhoto. I tried importing all the files again and upon doing so the images were uneditable. Double-clicking on them opens the editing window, but an exclamation point replaced the picture. This aparently also means I can't import them into aperture. Somebody please tell me I didn't lose 8,000 images.

    To read those images I'd say the only way is installing the iPhoto version you had before. Then try to read those photos from iPhoto. If it works, upgrade to the new iPhoto.
    After you've done that, I'd move the Aperture Library to the external HD, then launch Aperture and in Preferences point to the new Aperture's Library. Restart the program and import the photos within iPhoto to Aperture. After you've done that, you can delete the iPhoto Library if you are not going to use it again and move the Aperture's Library to your mac's hd.
    iMac 20" 2.1 Ghz 1.5Gb RAM   Mac OS X (10.4.7)  

  • How can I import my class or package in JSP?

    Hello.
    I develop jsp. When I assign variables in jsp, everything work fine. For Example:
    connStr="jdbc:oracle:thin:@191.168.0.1:1521:orcl";
    But I want put some variables inside class or package, so using text editor I created and compiled package:
    package Pack1;
    public class Test1 extends java.lang.Object {
    public static void main(String[] args) {
    String ConnStr = "jdbc:oracle:thin:@191.168.0.1:1521:orcl";
    or class
    class Test1 {
    public static void main(String[] args) {
    String connStr = "jdbc:oracle:thin:@191.168.0.1:1521:orcl";
    But as soon as I put in my jsp line
    <%@ page import="Test1" %> or <%@ page import="Pack1.*" %>
    I always have an error.
    JSP Error:
    Request URI:/DateN/search/Search.jsp
    Exception:
    oracle.jsp.provider.JspCompileException:
    Errors compiling:e:\orant\oem8i\apache\apache\htdocs\daten\_pages\_daten\_search\_Search.java
    C:\orant\oem8i\apache\apache\htdocs\daten\_pages\_daten\_search\_Search.java:12: Package DateN not found in import.
    import Pack1.*; (or Test1)
    ^
    1 error
    I using OEM2.2 with Apache-Server under Win2000. I put my classes:
    Test1 in package: in folder: C:\orant\oem8i\Apache\Apache\htdocs\WEB-INF\classes\Pack1
    If just class, when just in folder: C:\orant\oem8i\Apache\Apache\htdocs\WEB-INF\classes
    If I using just class, when I put just in folder: C:\orant\oem8i\Apache\Apache\htdocs\WEB-INF\classes.
    Im stack. Anybody can help?
    Thank you.

    Another way. You can use a USB flash drive & the camera connection kit.
    Plug the USB flash drive into your computer & create a new folder titled DCIM. Then put your movie/photo files into the folder. The files must have a filename with exactly 8 characters long (no spaces) plus the file extension (i.e., my-movie.mov; DSCN0164.jpg).
    Now plug the flash drive into the iPad using the camera connection kit. Open the Photos app, the movie/photo files should appear & you can import. (You can not export using the camera connection kit.)
    Secrets of the iPad Camera Connection Kit
    http://howto.cnet.com/8301-11310_39-57401068-285/secrets-of-the-ipad-camera-conn ection-kit/
     Cheers, Tom

  • How can i import my classes in jsp?

    Dear All,
    i want to access my classes in jsp. i am using apache tomcat
    server. let me know where i have to put my own packages and
    how can i use them in jsp.
    thanks

    Put them in directory /WEB-INF/classes under you webcontext. You can use them in your jsp by importing them or using the useBean directive.

  • Can't Import java class in form 10g

    Hi All,
    I have tried to call a web service from oracle form 10g
    so, I read your available document (How to call Web service from Form 10g)
    http://www.oracle.com/technology/obe/obe_as_10g/deploy/callws_fromforms/forms_webservice.htm#r1
    but when I've created a web service from WSDL file and I've deployed it to JAR file using Jdeveloper 10g (10.1.2.1.0).
    I tried to import it into form builder 10g but i have the error :
    java.lang.NoClassDefFoundError: oracle/jdeveloper/webservices/runtime/WrappedDocLiteralStub
    Please, can any body help me to solve this problem?

    Have you put the jar file in the classpaths??

  • Can't import own classes...

    I'm very new to java. I rented a book called Java 2 Grand Cru to learn it on my own. It is based on Java 1.3 but I have 1.4 installed. Now I wanted to write a simple program with a class in an other directory. I added that directory to CLASSPATH so my compiler could find it. These are the 2 programs
    import printer;
    public class test
         public static void main(String[] args)
              (new printer()).print();
    }and
    public class printer
         public void print()
              System.out.println("test");
    }So I want the first class to use the second to print "test"!
    Now I can compile public class printer without any problems but when I compile the first one, I get this:
    test.java:1: '.' expected
    import Printer;
                   ^
    1 error
    Process Exit Code: 1
    Time Taken: 00:00
    i don't get it. Is there anything changed with the import instruction in the new version of Java2?
    regards

    It is the error of my code but probably I did something bad with the copy paste thing :-)... The 'P' should be a 'p'
    Anyhow, I don't understand your first comment. 'printer.class' isn't a default package. I made it myself...
    regards

  • Help: Can't import old imovies from external drive unless I save on iMac

    Forgive me, I have read the similar questions in this forum, but I still need help.
    I made a great number of movies using the old imovie HD, and then saved all of them on my external hard drive. When I open up imovie 08 and look at the event library, it lists my hard drive with that yellow warning triangle and exclamation point on it (What does that mean?). Naturally, the old movies don't show up, so I try to import them manually. When I do, the new movies get imported on my imac. Is there any way for the imported movies to remain on the external drive? And should I be worried about the warning triangle? I should add that the external drive is a "My Book" that was originally used on a PC, and has also been used on my imac for the last 12 months with no issue.
    Thanks to all for your help.

    +I should add that the external drive is a "My Book" that was originally used on a PC+
    Then it is probably still formatted as a FAT partition, which has file size limitations that make it unsuitable for storing movies. You can check with "Disk Utility". For best results when used exclusively on a Mac, you should convert it to the Mac Journaled HFS file system with Disk Utility. The conversion will erase anything currently on the drive, so you will have to temporarily move the contents to another location.

  • Newbie help Can you import multiple ppro projects to encore

    Hello, I'm using CS4 and I have several seperate projects that I have worked on in Ppro.  I want to create a DVD that shows one of the projects upon start up.
    I then want to have menu options that will allow the viewers to select my other seperate projects and watch those videos.  Is this possible, or do I have to combine all of my little projects into one BIG project and do something.
    Please advise......I am very confused.

    I will for sure be in that forum.  So just to clear things up for me.
    I have done the dynamic link thing and it brings in my videos as Sequences/timelines like you guys said.
    The problem i was having is when I opened a different project in Ppro, i would go to dynamic link and it would open a different encore screen.  It would not import into the current encore project i was working on.
    Can I not do a dynamic link for the second, third, and 4th projects I want to bring into Encore with my first project?  Maybe that is my problem.....but i couldn't figure out how else to import these projects other than the dynamic link button.
    I will continue to play around with it, and will look for the bins you have told me about.
    If there is anymore help you could give, i would appreciate.
    thanks a ton.
    Mo

  • Need help - can't import some photos into iPhoto - getting error msg

    I have a lot of photos on my computer. Most of them are in my iPhoto, but I can't seem to load all of the photos in there and integrate them al. I am getting an error message. The jist of the message is that they are unreadable and that they cannot be imported. The photos are jpegs. I am kind of at a loss as to why these photos are not getting imported.
    Does it have anything to do with where the photos were taken from? What I mean is that when I have current photos on the camera, they will go directly to iPhoto. What about the ones that are copied to my hard drive from another computer? Those I can't seem to integrate into my library. An suggestions? Thanks.

    whatsupdut?
    Welcome to the Apple Discussions.
    Are these troublesome files in the iPhoto Library Folder? Are you putting files in there hoping to see them in iPhoto?
    iPhoto is a database, the images have to be imported (File -> Add to Library) before they can be seen. Also, as a precaution against duplication, iPhoto will not import pics from the iPhoto Library Folder, so move them out to the desktop and then import them.
    Regards
    TD

  • Need help: Can't import old video into Final Cut Pro X or iMovie

    I am trying to import some footage from my old camcorder into my iMac.
    I have a Sony DVMC-DA1 connected via firewire. The setup works great in iChat. We were able to video chat to my wife's computer and she could see and hear the camcorder footage. iMovie does not recognize the device at all. Final Cut Pro recognizes it. It appears in the Camera Import window, but when I try to import some footage, nothing gets recorded. Oddly, there are two time counters in the import window. The one on the left increments as the footage 'imports' but the one on the right stays at zero.
    My iMac is the newest 2011 model and I am using the latest versions of iMovie and FCPX.
    How do I get either iMovie or FCPX to import my footage from the DVMC-DA1?

    This guy did a tutorial for 2 free ways of importing video over FW:
    http://www.youtube.com/watch?v=rVqkSlaTr-k
    They both should accept any video over FW. The link for Vidi is old, here's where to find it: http://www.mitzpettel.com/
    Good luck.

  • How to import a .class in eclipse?

    I have a .class file w/ out the source, and im tiring to import that into my project.
    So I go to import->File System and check the .class file. It shows up in my project but when I try to instantiate it I get a "can not be instantiated to a type" error.
    any thoughts?
    this is happening to a lot of people in my course.
    thanks!

    Hi,
    i tried that what you sad, but my eclipse can't import that class.
    So: I have eclipse 3.1, and i would like to import a class (without source). I develop at the moment a J2ME project with eclipse.
    The class what i want to import is in a package, so i must to import like this: import net.jscience.math.kvm.MathFP;
    Can you tell me how in the hell can i this class to import?
    (I tried about 6 hours long, and i got some result, but not the really perfect.)
    When i make this subdirectory structure (what is in the import line) into my project, then in eclipse work the auto completing, 'till the class name. :-/. But the class is there. Egal i add an external class folder, i got always the same result.
    Please help me, because my brain at the moment wants to explode.
    Thanks a lot.

Maybe you are looking for

  • Objects in slideshow out of sync?

    I noticed after a few repetitions the images that disappear on one side and reappear on the other start to get out of sync with each other, eventually overlapping. I'm figuring that has something to do with the minute timing differences between the l

  • Lion install did not update background/screen saver images

    I installed of Lion on my Macbook and it did not update the background/screen saver images with the new ones, anyone know why?

  • How to install my turntable with pc link function

    Can someone please help me, II got a turntable with pc link function for Christmas but I don't know how to install it on my MBP OS X Yosemite. Also where to download an  apple approved audacity software?

  • Newbie question: Saving User Data on iPad

    Hi I am working on an App for iPad in Flash CS5.5. In the app the user will be writing poetry and saving text on the iPad locally. I need them to be able to decide which poem they load back into the app. It seems to me this will qualify ofr saving to

  • Error message? Unable to contact the FaceTime server.

    Have new imac and I get this error message: Unable to contact the FaceTime server.  All mty other apple devices can connect but not my iMac.