How to create package and import from jar file?

Hi all,
I am writing a software and I am not sure how to create a package for the classes.
Say I have two classes in the same directory as follows:
testA.java
==========
package AB;
public class testA
public static void main(String[] args){
     testB myB = new testB();
     System.out.println("A test");
testB.java
===========
package AB;
public class testB
public testB(){
     System.out.println("B constructor");
both file compile without the package heading;
both file compile using: javac -classpath .\ *.java
Question 1:
I cannot run testA by: java -classpath .\ testA
I think it is a syntax error. What is the correct one?
If I run testA by: java testA
The only output I get is: A test
But I am expecting: B constructor /n A test
What went wrong?
Question 2:
I need to use APIs of another software. I have downloaded a .jar file (xxx.jar) with all the classes in it. And I have put "import xxx.*;" in my source file. But the compiler complains about the importing. What is the right way to copmile it?
I have read a couple of tutorials but they don't answer my question.
(I am using windows2000 and don't have the classpath variable.)
Hope some one can help.
Thanks a lot

Try moving testA out of the package and importing 'AB.*;'
If you have:
./testA.class
./AB/testb.class
Then to execute testA from ./ type: java -cp . testA

Similar Messages

  • How to extract html file and folder from jar file

    Hi all ,
    I should to submit my project tomorrow . plz help me .
    In my project jar file I have html page that should run when I use the program, I can't extract it . Also it have folder that contain some files that My program should use it . I dont know how to use it from jar file or how to extract it . plz help me.
    If you could I need java could for that.
    Thanks alot.

    Hi all ,
    I should to submit my project tomorrow . plz help me .
    In my project jar file I have html page that should run when I use the program, I can't extract it . Also it have folder that contain some files that My program should use it . I dont know how to use it from jar file or how to extract it . plz help me.
    If you could I need java could for that.
    Thanks alot.

  • How to load date and time from text file to oracle table through sqlloader

    hi friends
    i need you to show me what i miss to load date and time from text file to oracle table through sqlloader
    this is my data in this path (c:\external\my_data.txt)
    7369,SMITH,17-NOV-81,09:14:04,CLERK,20
    7499,ALLEN,01-MAY-81,17:06:08,SALESMAN,30
    7521,WARD,09-JUN-81,17:06:30,SALESMAN,30
    7566,JONES,02-APR-81,09:24:10,MANAGER,20
    7654,MARTIN,28-SEP-81,17:24:10,SALESMAN,30my table in database emp2
    create table emp2 (empno number,
                      ename varchar2(20),
                      hiredate date,
                      etime date,
                      ejob varchar2(20),
                      deptno number);the control file code in this path (c:\external\ctrl.ctl)
    load data
    infile 'C:\external\my_data.txt'
    into table emp2
    fields terminated by ','
    (empno, ename, hiredate, etime, ejob, deptno)this is the error :
    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 5
    C:\>any help i greatly appreciated
    thanks
    Edited by: user10947262 on May 31, 2010 9:47 AM

    load data
    infile 'C:\external\my_data.txt'
    into table emp2
    fields terminated by ','
    (empno, ename, hiredate, etime, ejob, deptno)Try
    load data
    infile 'C:\external\my_data.txt'
    into table emp2
    fields terminated by ','
    (empno, ename, hiredate, etime "to_date(:etime,'hh24:mi:ss')", ejob, deptno)
    this is the error :
    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 5
    C:\>
    That's not an error, you can see errors within log and bad files.

  • How to create a java card library (jar file to be used in other programs)

    Hi all,
    I am working on JCOP and writing quite a bit of applets for the java card . Now i have lots of code that could be reusable for example sending SMS, encryption routine, etc.. So this part of the code i want to put into a utility class and create a package out of it. This utility package i must be able to import into my programs what i write.
    I tried the normal way of creating the jar by renaming the CAP file of the utility class, also tried including the /javacard/* files also into the jar file as indicated by sfarmer(active forum member here). But none seems to work. I tried contacting NXP folks and they indicated that it may be possible only by way of Sharable Objects.
    But some how i am not convinced why i should use Sharable object for this. So if any one can throw some light into this regard it will be immensely helpful to me and my project.
    Regards
    Prakash

    Hi,
    Well the variable defined are as below
    public static byte[] msgdata = new byte[255];
    private static final byte[] HEADER_TEMPLATE = {
              (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, // Command details tag
                   (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x02, // Device Identities tag
                   (byte) 0x8D, // Text String tag
                   (byte) 0x00, // length
                   (byte) 0x04, // Text String tag
    the msgdata is declared public so that i can access this as a Class member in my other program doing Utilities.msgdata. But the problem is now that if i dont declare it as final then the compiler gives me the below error
    "library has initialized array for non-final, non-static field Utilities, msgdata, [B, attr jc-field: tok 0, public static"
    If i make it final then i cannot change it... So now i am stuck..
    Any help will be highly appreciated...
    Regards
    Prakash                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to Clear Iphoto and Rebuild from another file, not Iphoto Library?

    I have over 7000 images. Some of the Iphoto thumbnails are from my desktop file and some from the DATA file copied into Iphoto. I want to rebuild my thumbnails using all of the pictures on my desk top, not copying them/duplicating into Iphoto. The reason I want to rebuild Iphoto is years ago while copying and moving pictures on another PC the picture data was deleted and the date data of the pics was lost. If I load the images, Iphoto mixes the images up. I have organized all the pics on my desktop into folders by month and year. When I tried to rebuild, old photos show up again so I deleted the original Data (photos) in Iphoto and after rebuilding they reappeared with many images just black boxes. I was expecting a blank page so I could start to build the thumbnails from my desktop folders.
    How do I get a blank screen/no images in Iphoto? Select all the images and drag to trash? To be safe I have all my pictures saved on 2 ext hard drives. Also can a select a group (i.e. by month) and change all the date info at one time?
    If you can help...THANKS

    BgMc
    It’s difficult to advise you because you’re using non-standard terms. I’m worried that if I misunderstood something that I might give you a bum steer.
    Some general principles: Don’t “clear iPhoto”. Instead make a new Library: Hold down the option (or alt) key key and launch iPhoto. From the resulting menu select 'Create Library'.
    When you have this new Library working you can delete the old one.
    In general, if you have a Folder of images and you drag them to the Source (or left-hand) Pane in iPhoto the pics will be imported and a new Album and Roll will be created. This may help.
    Some of the Iphoto thumbnails are from my desktop file and some from the DATA file copied into Iphoto.
    I have no idea why you would want thumbnails. Surely you want the full sized files? What’s a desktop file? Do you mean Desktop Folder?, also what’s a DATA file?
    I want to rebuild my thumbnails using all of the pictures on my desk top, not copying them/duplicating into Iphoto.
    This makes no sense to me. Why are you rebuilding thumbnails? And if you don’t want to use iPhoto then why are you posting here?
    so I deleted the original Data (photos) in Iphoto and after rebuilding they reappeared with many images just black boxes
    Here’s a really good general principle:
    Don't change anything in the iPhoto Library Folder via the Finder or any other application. iPhoto depends on the structure as well as the contents of this folder. Moving things, renaming things or otherwise making changes will prevent iPhoto from working and could even cause you to damage or lose your photos.
    Regards
    TD

  • J2SE 1.4 cannot import from JAR files

    Windows 2000
    J2SE 1.4.0
    Textpad (IDE)
    Everytime I attempt to use a package from a JAR file, I get a "package _name_ does not exist" during compilation. If I un-jar the package, then the compilation runs normally.
    I am putting the JAR files in c:\program files\j2sdk1.4.0\lib and my classpath is set to .;c:\program files\j2sdk1.4.0\lib. I don't think its a classpath problem though, because it only occurs with JAR files.
    Textpad performs the following command to compile: javac filename. Manually compiling does not help, nor does using the -classpath option.
    It is as if javac is not looking in the JAR files, and like I said if I un-jar the package, everything compiles normally. This has been driving me crazy for a couple of months now, and I would really appreciate any hints anyone can give me as to what might be causing this.
    Thanks,
    Jeremy Figgins

    I just decided to check if it was possibly a bad installation; the problem occurs on my other Win2k machine as well, so that precludes that possibility. The directory structure on the other machine is slightly different as reflected by its CLASSPATH:
    .;C:\Program Files\java\lib
    Thanks,
    Jeremy Figgins

  • Java Plugin and GIFs from Jar file...

    This used to work and I haven't looked at it for a while. First thing I did is run the old java applet web page with the old jar file, kinda just to lay eyes on the thing again.
    It had to download a new plug-in from Sun, and upon doing so, reports a new error indicating that the value for the cache_version attribute in the HTML is incorrect. It was 1.0 (always has been) and the plugin says it needs to be in X.X.X.X format instead.
    So, that isn't a nice change to make in the plugin at this time. However, if I just click okay and close the error dialog, at least it works fine after that.
    In my attempt to get rid of the dialog I change the cache version to 1.0.0.0, upon doing this
    the toolbar images no longer load, it says there is a java.io.FilePermission error.
    We'll it doesn't make any sense that a mere change to cache version caused that so I changed the version back to the apparently erroneous value of 1.0, and then the toolbar images work again ! But I get the permission error.
    Any ideas how I can fix these pesky images loading from a jar ?
    Do you have any code that loads images out of a jar in an applet succesfully ?
    Or have any suggestions on what I could try ?
    Below is the code I'm using to load the images, where icoXXXX is a ImageIcon object, and fileameXXXX is a string containing a relative file path such as "images/highcolor/toc_color.gif" (this code executes in the applet's init() method (called by the plugin):
    java.net.URL urlToc = getClass().getResource(filenameToc);
    java.net.URL urlTocBW= getClass().getResource(filenameTocBW);

    dunno why but
    getClass().$blah... wouldn't work for getting images in an applet from a jar for me.
    But this does:
    Class c = Class.forName("java.lang.Object");
    InputStream in = c.getResourceAsStream("/images/myImage.gif");
    byte[] buffer = new byte[in.available()];
    in.read(buffer);
    icon = new ImageIcon(buffer);
    when included with the usual default exception handling.
    Lemme know if that doesn't work for you.
    cheers
    -Ragu
    Overweight is when you step on your dog's tail and it dies.

  • How to create a inbound IDOC from flat file in Application server

    HI All
    Our requirement is to create the Inbound idocs from a flat file from application server with in R/3
    Could any body please let me know the steps required for this.
    Thanks
    Malli

    1. Read the file using OPEN DATASET and read and fill up the segment info and fill the EDIDC header data
    and then call function
    CALL FUNCTION 'INBOUND_IDOC_PROCESS'
        TABLES
          IDOC_CONTROL       =  i_edidc
          IDOC_DATA          =  i_edid4.

  • Please tell how to use package and import?

    Hi,
    My classes are in different packages
    for eg
    package manage.ui
    package manage.data
    package manage.layer
    if I try to import
    import manage.layer.*;
    in a class in manage.ui
    it shows
    package manage.layer does not exist
    Please help to find the problem?????

    Are your classes placed in a folder stucture that mirrors the package structure? So, like this:
    -manage(folder)
    --ui(subfolder of manage)
    --data(subfolder of manage)
    --layer(subfolder of manage)

  • How to create a Help page from a file

    Hello,
    I have a new APEX application and someone made a nice help document using MS Word.
    How could I inlcude that file into a Help Page, or some ideas on how this could be seen by the users?
    Thanks

    Hi,
    Apex has a facility whereby you can create a context sensitive help page facility.
    see http://download.oracle.com/docs/cd/E23903_01/doc/doc.41/e21674/bldapp_hlp.htm#CHDCDBFB
    With your help document, save the section relevant to a page as a separate document and save it as a filtered web page. Edit this document in a plain text editor and cut and paste this into the help text for the page.
    When you select help from the navigation bar, then this help text will be shown for the current page. To make it even fancier, you can define the link for the navigation bar to show the help page as a popup, so that you don't loose the current context in the application.
    Regards
    Andre

  • Address book sync creates duplicate contacts imported from .cvs file

    Contacts on my iPod are weird--there are duplicate entries for some people, but one of the duplicates contains only email addresses whereas the other has all the remaining info. Everything seems normal in Addresss Book--no duplicates, and all the info. is there. Not all of my contact entris have this this duplication/split info. problem. Those that have the problem were originally imported into Address Book from an Excel .cvs file. I also sync with a Motorola Razr and the same names were duplicated fully on the phone, with each entry having all the phone numbers that should have been synced. Anyone know what's going on or how to fix this?

    Hi and welcome to the BlackBerry Forums
    I never hear this, but try this.
    If you have all the correct data in outlook, my suggestion is wipe the device (all the data is erased) and synch the device again.
    To wipe the device go to menu,  options, security options, general options, press menu, and wipe handheld.
    If I help you with any inquire, thank you for click kudos in my post.
    If your issue has been solved, please mark the post was solved.

  • How to remove Header and Footer from Flat File

    Hi,
    In a scenario , we are going to recieve a flat file which will contains header , footer and data. We have to have to load data in Oracle tables and remove header and footer.
    once the data load is complete , we have to delete flat file from source directory.
    Please help me in solving this issue.
    Thanks,
    Kamlesh

    You have a header parameter in the file datastore. You can provide any number to skip rows from top of the file. For footer you can create a filter in staging area.
    Filter coould be something like this.
    where source_alias.source_column not like '%FOOTER_OR_ANY_VALUE_AS_PER_YOUR_REQ'

  • How delimited by header and footer from Source file in BPEL 11g

    Hi Friends,
    I have source data below like This..
    SOFTWARE COMPONENTS:
    BPEL 11G,
    J DEVELOPER(11.1.1.3)
    FILE READ ADAPTER
    WEB LOGIC EM SERVER(10.3.3.0)
    1|10005|857896|BR |0000 |6544|kantro|54635
    1|10265|69875|.36544|2456112|00000|000000|00000|SE|5456|466554|789745|54.325|KVM|56476.32
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|45669
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|45664
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55776|4454544|45660
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|85668
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|45666
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|85876|4454544|45666
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|55566|4454544|69848
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|69566|4454544|45666
    1|10235|JA|5456|4565|56|656|5855|5555|55445|5444|D|45457|0000|KIL|6555|78966|4454544|85669
    1|10255|km|5653|RJ |00000|5557544|13-08-1998
    But i need to Delimited and insert the data into table ..Here Header data insert into saperate table and
    middlle of the data insert into main table and footer data insert in another table it all happen one attempt by using file read Adapter(11.1.1.1.3)

    You have a header parameter in the file datastore. You can provide any number to skip rows from top of the file. For footer you can create a filter in staging area.
    Filter coould be something like this.
    where source_alias.source_column not like '%FOOTER_OR_ANY_VALUE_AS_PER_YOUR_REQ'

  • How do I find and import Liquid Ledger files after a re-install

    I had to re-install my os x system and I chose to save my files. I have re-imported all items such as documents, pictures and addresses, but I do not know how to import my Liquid Ledger files. I do not know where they are. If I have re re-enter 4 months of accounting I will scream.

    You might want to ask in the Liquid Ledger Support Forums

  • How to create a link (path) from a file.

    Hello,
    I'm sending an email out and would like to tell the team where a graphic file (illustrator file) is located. I've seen in other emails where it comes in a form of a link (i.e.,  file://localhost/Volumes/creative/Active/VISUAL/.....20ENDCAP%20-%20JULY-AUG%2012.ai); click on this link and takes one directly to the graphic file. I've tried control clicking on the file (MAC platform) and didn't see anything remote indicating a link.
    Does anyone has insight to this question?
    Thanks!
    Suta

    1. Read the file using OPEN DATASET and read and fill up the segment info and fill the EDIDC header data
    and then call function
    CALL FUNCTION 'INBOUND_IDOC_PROCESS'
        TABLES
          IDOC_CONTROL       =  i_edidc
          IDOC_DATA          =  i_edid4.

Maybe you are looking for