Package Keyword

Is it possible to upgrade the version of Check?
I noticed a feature in the solaris 10 jumsptart profile package keyword where you can add packages via http & ftp. This is a neat feature and I would like it to work in Sol9. Any ideas on how to go about this?
Thanks
-slr

When you name a package for a class, the fully qualified name for the class is the package name plus the class name, in your case the package name seems to be suncertify.db and the class name is Data so the fully qualified name is suncertify/db/Data (or suncertify.db.Data). If you don't specify a package, then the fully qualified name is just the class name.
When you launch an application using the java command, you must use the fully qualified class name. In your case, it appears you used "java Data" When the JVM found a Data.class file, it expected a class whose fully qualified name is Data but it found the class suncertify/db/Data - thus the class it found had the wrong name.

Similar Messages

  • NoClassDefFoundError when I use "package" keyword

    Hi,
    When i put the class into a package, i got the following error message:
    "Exception in thread "main" java.lang.NoClassDefFoundError: Data (wrong name: suncertify/db/Data)"
    But when I delete the "package" keyword, it works fine. why is that?
    Thx.
    adrian

    When you name a package for a class, the fully qualified name for the class is the package name plus the class name, in your case the package name seems to be suncertify.db and the class name is Data so the fully qualified name is suncertify/db/Data (or suncertify.db.Data). If you don't specify a package, then the fully qualified name is just the class name.
    When you launch an application using the java command, you must use the fully qualified class name. In your case, it appears you used "java Data" When the JVM found a Data.class file, it expected a class whose fully qualified name is Data but it found the class suncertify/db/Data - thus the class it found had the wrong name.

  • Creating a package in sql*plus

    Dear all;
    Do you know what is wrong with this statement
    SQL> create or replace pkg_initial_comment as procedure save_initial_comment(p_i
    d number, p_first_name varchar2, p_last_name varchar2, p_comment varchar2, p_dat
    e date); end save_initial_comment; create or replace package body pkg_initial_co
    mment as procedure save_initial (p_id number, p_comments varchar2, p_first_name
    varchar2, p_last_name varchar2, p_date date) is begin insert into initial_commen
    ts values (1, p_first_name, p_last_name, p_comment, sysdate); end save_initial;
    end pkg_initial_comment;
    create or replace pkg_initial_comment as procedure save_initial_comment(p_id num
    ber, p_first_name varchar2, p_last_name varchar2, p_comment varchar2, p_date dat
    e); end save_initial_comment; create or replace package body pkg_initial_comment
    as procedure save_initial (p_id number, p_comments varchar2, p_first_name varch
    ar2, p_last_name varchar2, p_date date) is begin insert into initial_comments va
    lues (1, p_first_name, p_last_name, p_comment, sysdate); end save_initial; end p
    kg_initial_commentI keep getting the following error message
    ora-00922:
    and my table structure is below
    create table initial_comment (id number(30),
    first_name varchar2(4000), last_name varchar2(4000), create_date date);

    yeah I just realized all my problems, it wasnt just the package keyword, it was also the names were wrong in both the specification and body. I am not used to using sql*plus, i use all other client tools which gives an opportunity to see and understand my syntax clearly. sorry about the posting and formatting. thanks for the help

  • Package Problem

    I'm new to Java and am self teaching myself. I have run into a problem that I can't figure out. I have the following code that works fine, however, when I add the package keyword the program does not compile and gives errors. The following code works without any hitches:
    public class printMe {
    void printThis(String s) {
      System.out.println(s);
    class application {
    public static void main(String[] args) {
      printMe pm = new printMe();
      pm.printThis("hello");
    }Now if I add package to them as follows:
    package intro;
    public class printMe {
    void printThis(String s) {
      System.out.println(s);
    package intro;
    class application {
    public static void main(String[] args) {
      printMe pm = new printMe();
      pm.printThis("hello");
    }I get the following error when I compile application
    can not find symbol printMe in printMe class. Any help would be appreciated.

    Well you're doing something wrong....
    When I save this as Application.java
    package intro;
    public class Application {
    public static void main(String[] args) {
      PrintMe pm = new PrintMe();
      pm.printThis("hello");
    }and this as PrintMe.java
    package intro;
    public class PrintMe {
    void printThis(String s) {
      System.out.println(s);
    }both of those in an intro directory.
    Then I go in the directory below and go
    javac intro/Application.javait compiles just fine.

  • Where to package

    hi I'm gind of new to java and I was wondering after I add a file to a package with the "package" keyword where do I put it and do I compile it?

    it was helpful but it didn't answer all my questions
    where do you put the file?You can put it wherever it is convenient, as long as the directory structure and Classpath are correct. For example, you might want to keep the .class files separate from the .java files. For a Windows machine you could create a directory c:\myjava\myclasses and c:\myjava\mysources. Then put your projects into the mysources directory. You can use the -d option of javac to compile your code into the myclasses directory. If you put c:\myjava\myclasses into your system Classpath, then everything will work.
    can you put it in the src.zip folder?I wouldn't. If you upgrade the j2sdk, then you will get a new src.zip. You can put packages into jar files.
    do you have to compile it so it will be in the
    package?By putting the package statement into the source code, it will be compiled as a packaged class. However, it must be in the correct directory structure to use the class. You can put the source into the right directory and the compiler will generate the .class file there. Or you can use the -d option of javac. Or you can manually move files to the right directory. As long as the .class file
    can you put two package statements in the same file?No. Packages are used to manage access and namespaces. A class has a fully qualified class name which is used to uniquely identify the class. The fully qualified class name is the package name plus the class name.

  • Java package

    Hi I'm facing some problem with package. Currently my project import some classes from the file abc.jar. Before including the package keyword for my new class, everything compiles.
    However after I tried adding for example package testing; at the top of the .java files. I begin to get error like:
    cannot resolve symbol class xxx -> which is suppose to retrieve from abc.jar. The first thing that came into my mind is the classpath, have double confirm on the classpath for the .jar files and its already specified in the classpath. The thing that puzzle me is why adding my new class to a package will have compilation error like the above.
    Anybody faced this problem before or have little hint on how to solve it? Kindly post your advice. Thanks! cheers

    xpy wrote:
    Hi, its that statement.... Cause I tried compiling with and without the package keyword and the result is fail and success respectively.This tells us very little other than that you're probably making a mistake. Most Java code is in packages; this works for most people.
    Its really puzzled me. Btw the way the .jar file which I set in my classpath have no directory. Wait. Do you mean to say that the classes in the jar file are all in the default package?
    Who created this crazy jar file?
    When code is in a package, it cannot access classes in the default package. This is why it's generally bad to put classes in the default package if they're non-trival. You certainly shouldn't any class that you expect to be reused and thus might put it in a jar file, in the default package.
    Therefore after setting the classpath to point to the .jar file, therefore I use it directly in my new class without importing. Do you think this is the reason that caused the problem?Yeah.
    Stop using that jar file, because the person who created it doesn't know what he's doing.

  • Problem creating packages

    hi...
    i'm trying to create a package so that i can access the members of other classes. How ever after putting the package keyword on top of each file etc:
    package gui;
    i still can't access the other files. do i have to make it a jar file. if i don..how should i do it...thanks...

    no u dont need a jar file to have a package
    put all your package files into a folder called the name of the package
    then import them as you need with import packagename.*if you just want to use the classes without a package just do
    classname x = new classname();
    x.whatever_method_you_want();

  • Packages cannot be nested

    I'm a newbie and have started a simple tabbed mobile project.
    I keep getting "packages cannot be nested".
    my main mxml file:
    <?xml version="1.0" encoding="utf-8"?>
    <s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                                                                      xmlns:s="library://ns.adobe.com/flex/spark">
              <fx:Script source="cBut/cFields.as">
              </fx:Script>
              <s:ViewNavigator label="Results" width="100%" height="100%" firstView="views.ResultsView"/>
              <s:ViewNavigator label="Setup" width="100%" height="100%" firstView="views.SetupView"/>
              <fx:Declarations>
                        <!-- Place non-visual elements (e.g., services, value objects) here -->
              </fx:Declarations>
    </s:TabbedViewNavigatorApplication>
    my .as file:
    package
              public class cFields
                             public function cFields()
    what am I doing wrong?
    thanks

    The <fx:Script source="cBut/cFields.as"> tag will insert your cFields.as file into the MXML file (similar to an include in C/C++). That will cause an invalid syntax, as you've noticed.
    Give your package a name (in this case it should be called cBut because that is the name of the folder it is in) then use the import statement inside your script tag. Make sure you adhere to the recommended file, namespace, package and class naming structure. That's usually a reverse-DNS style: com.adobe.utils.bla.bla.bla.
    If you package name is blank and the source is in the default folder, you don't need to import it.
    Look up the package keyword in the help.

  • Install single package from testing

    I just switched to Arch from Gentoo, and so far it's been mostly great. What I want to do right now is install 1 package from testing, and only that one. Is there an easy way to do this, besides uncommenting the testing repo, installing xorg-server, and commenting testing again? Basically (if you're familiar with Gentoo and emerge), I want to know what pacman's equivalent to /etc/portage/package.keywords is. Alternatively, if there's a way to make kde4 not absurdly slow with a relatively new ultra-low-end nvidia card (9300m), then I'm up for that as well. Additional background for this question is that I was hoping the newest (beta) drivers might alleviate this issue, but they depend on an xorg-server version that only exists in testing. I don't want to run testing, but if the new drivers help, then I'd be willing to run them (along with any reasonable, if unstable, dependencies). Thanks in advance.

    shimage wrote:I just switched to Arch from Gentoo, and so far it's been mostly great. What I want to do right now is install 1 package from testing, and only that one. Is there an easy way to do this, besides uncommenting the testing repo, installing xorg-server, and commenting testing again? Basically (if you're familiar with Gentoo and emerge), I want to know what pacman's equivalent to /etc/portage/package.keywords is. Alternatively, if there's a way to make kde4 not absurdly slow with a relatively new ultra-low-end nvidia card (9300m), then I'm up for that as well. Additional background for this question is that I was hoping the newest (beta) drivers might alleviate this issue, but they depend on an xorg-server version that only exists in testing. I don't want to run testing, but if the new drivers help, then I'd be willing to run them (along with any reasonable, if unstable, dependencies). Thanks in advance.
    Welcome to the forums.
    If you upgrade only xorg-server, you're going to have problems. There are other packages designed to be used with it.
    With that being said, you can always put testing as the last repo in /etc/pacman.conf. Then if you want to upgrade one package, you explicitly call it with pacman -S testing/<package_name>.

  • My thoughts (and yours too!) about Arch (I'm in love already!)

    Hello all!  I suppose I would be called a newbie to Arch, but certainly not to Linux.  I've been running Gentoo for five months.  If I were running, say, Ubuntu for five months, I would probably still be considered a newbie, but five months of Gentoo has made me pretty proficient at Linux.
    I (if you haven't guessed yet) am a Gentoo user , and it seems like there are a lot of Gentoo users who go to Arch.  That's how I heard about it, through the Gentoo forums.  I am currently looking for backups in case Gentoo comes crashing to the ground.  I was perfectly content in my little bubble of happy compiling until I learned about the unrest inside of the Gentoo community.  I never realized that things were in such bad shape... like a downward spiral.  The result cannot be good.  I feel like I'm on a sinking ship and am praying for my life here.  I've seen a lot of threads at the forums lately like "If Drobbins fork Gentoo, will you follow him?" and "Will you stay with Gentoo if the Foundation is handed over to a 3rd party?"  I find these a little unsettling!  I understand that the Foundation is a terrible state right now, and the founder's attempt to get it back has failed, so now I don't things are going to head up.  So I've started to face facts, that I better have some backup plans so that I'm not starting over from square 1 when this all burns to the ground (hopefully if, not when, because I like Gentoo and really don't want to have to give it up).  Now I admit that I don't like EVERYTHING about Gentoo, but I like almost everything, and Arch seems to be like Gentoo in many respects.
    Some of my personal desires in a distro:
    1.Bleeding edge with rolling updates (and thus no need to ever reinstall the distribution)
    2. A large repository for the package manager
    3. Not a newbie distro... a distro for those who like the command line and to do things themselves
    4. Good community
    5. Customizable
    6. The ability to choose between a stable and unstable package on a per-package basis
    7. Install from source
    Arch seems to satisfy 1,3, 4, and 5 correct?  And pretty well satisfies 2, though I can see its package manager is not as big as Gentoo (though bigger than like Slackware).
    I guess for the most part it doesn't satisfy 6 and 7 though, right?  I realize that AUR is source-based, but on the whole, Arch is binary, so I'm referring to the overall tendency of the distribution. 
    Is there the ability to choose between stable and unstable packages though, to be as bleeding-edge as possible? (I'm thinking no but thought I'd ask)
    Many other distributions such as Ubuntu probably wouldn't meet my needs at all.  They seem to have a great repository and community, but I just don't want a GUI-based distro.  The truth is, I want to feel like my computer needs me.  It's my baby.  XDDDD  Okay, that's pretty sad, especially because it's a Pentium II (I can't WAIT to get my new laptop!!!!!!!!!!!), but I appreciate my Gentoo box way more than our Windows box upstairs, a lot of that having to do with the work I had to put into it to get it working correctly, and all that I had to learn.  It makes me appreciate it a lot more, and it makes me a lot better at solving problems.  (If it ain't broken, why not break it so you can fix it? XD)I don't want a distro that does everything for me; I won't feel needed anymore.  Plus, I'm addicted to the command line.  I have a window manager, sure (Thunar with Xfce), but I mostly still use the command line to view my files.  Sometimes I don't even start up X (I never start it up by default) and am just as efficient as when I have it open.  I insist on knowing how to do everything manually... when I wanted to make keyboard shortcuts for X, I chose to use xbindkeys rather than use the GUI with Xfce, so I could do it manually and still have it working if I ever switched desktop managers.  I manually edit pretty much ALL my config files and, like  I said, I am just as efficient without the GUI as I am with it.  I can't go five minutes in GUI without having a virtual terminal open.    So I think, in these respects, Arch would meed my needs quite well, just as Gentoo does now.  I have deiced to try out Arch now anyway, regardless of the state of Gentoo, because you know, i might just like Arch better.  I know a lot of Gentoo users have said they've gone to Arch.    I'm trying to get my friend Evan to let me use his 8 gb hdd to try it on, because my current 6 gig drive for Gentoo is like... 99 percent full (I swear, I'm not kidding, I have 100 mg left, I REALLY have to prune XD), so once I get it, I'm going to install Arch (after unhooking my /home hard drive because I only have two slots for hard drives, and they're both already filled!  I will probably end up moving the /home directory onto that 8 gig drive anyway.  I realize it's hard to share things between distros, but I will at least be able to have a place to put files for both distros in the same place and would probably end up symlinking some same location to my desktop for both distros
    Okay, now I'm just ranting.  Back to point!  I'm definitely going to try out Arch, and so far I like what I see. I even recommended it to a friend who is also thinking of leaving Gentoo (for Ubuntu, so he can support his amd64 processor).  I pointed out Arch64 and he's considering it. I don't think he'd like Ubuntu any more than I.  He originally used Slack and only switched to Gentoo because Slack really doesn't have a good package manager.  I think he'd like Arch as well.
    I've also done research on other distributions someone like me might like (especially coming from Gentoo).
    This is my current list:
    Arch Linux
    Frugalware (based on Arch, right?)
    Zen Walk
    Vector Linux
    CRUX (I'm leaning away from this one, as of now)
    Lunar
    Source Mage
    Sorcerer
    FreeBSD (but I've decided not to go with FreeBSD, as much as I like installing from source, because their philosophy of stability over currentness (like not having flash 9 because it's not "stable") just doesn't fly with me.. Linux is better for me, I think)
    LFS.. okay, not really, but if I ever have a weekend when I'm REALLY bored.........
    I've used Slack before but I would prefer to have a package manager, so I'm steering away from that direction, as much as I liked Slack.
    Have I missed any other distros people in this sort of mindset like us might like?  ^_^ 
    My primary focus right now is Arch, and it's definitely my first preference as far as switching goes.
    I think my biggest problem with Arch is that I REALLY like to compile everything from source (or at least, have Portage do it for me :-p), so I"d miss that.  Especially USE flags.  However,  Source Mge/Lunar/Sorcerer don't sound as good as Arch, and FreeBSD just... isn't my thing.  Their package manger seems great, it's their overall philosophy I disagree with.
    This post really isn't asking for help with anything, but isn't that fine?  This is just the Arch Linux General Forums, right?  I just wanna talk about Arch as compared to other distros.  I've wiki-ed it some, but I just think it's a fun thing to discuss.
    So what things do you guys like better about Arch, and what things do you like better about Gentoo, or maybe about some other good distros?
    I can't wait to try out Arch; I'm so excited!  No Xubuntu for me! ^___________^ (Gnome and ESPECIALLY KDE would lag far too much for this computer)
    -Megan M-

    Well, I technically have 14 gigs... I have the 6 gig and a 4 gig which has /usr/portage (the portage tree probably takes up so much space it would outweigh any space saved through USE flags XD) and /var/tmp, since that can get huge while compiling and I don't have space on the 6 gig for the fluctuations in space... I had to install the binary for OpenOffice just because the temporary space required to compile it was bigger than the space I had on my hard drive!!!!and I actually have so little space left I am permanently using a ext3 formatted flash drive as my ~/Desktop (it's in my fstab and everything XD!)  This gives me 4 extra gigs for all my stuff.
    But anyway, just you people answering this thread so nicely confirms my feelings about the Arch community.  I can easily see a thread like this simply being ignored on the Gentoo forums, or just merged with other threads.  >.<
    Actually, to be honest, most pakcages I am running unstable on Gentoo had to do with compile errors and such, or some feature not working correctly in the older version.  The only ones that I just wanted to run unstable are.. lemme check my /etc/portage/package.keywords... Skype and Pidgin.  And possibly Mplayer too, I was thinking of.  Everything else was either because of problems or of it being in the Sunrise overlay (everything in there is masked as unstable since it's not an official part of the Portage tree).
    How easy is it to get an older version of a package?  I ask because I want Flash 9.0.48.0-r1, NOT 9.0.115.0.  The newer one made my Firefox commit suicide and just close with an error when I viewed certain pages (youtube, etc. was fine, but even going to www.adobe.com made it crash *irony*).  Gentoo forum users told me that then newer one was unmasked because of a security flaw found in the older one, but for me, I'd rather take my chances with the hole than have firefox crash every five minutes!!!!  Is there any way to specify not to update a package either, for when you do a world update (or whatever they are called in Arch)?  This also has to do with Flash... I'll give the newer one a try... maybe it was just a Gentoo issue... but if not, I'm DEFINITELY downgrading!
    I like how easy it seems for Arch users to add packages to AUR so they are available to others... this is harder to do on Gentoo, despite that everything is source-based.  It's most like there is a wall between the users and the developers that cannot be broken easily.  This seems like a good way to let users have a little fun in the developer's world without *being* one.
    One last question while I'm here.. my other friend who I sugested Arch to... I just want to confirm that Arch would support his CPU.  He said to me:
    "Oh, and my CPU arch is amd64 / x86-64 / emt64-t
    thechnically its em64t since its an intel CPU but i am running a k8 optimized system (because I used to have a opteron)"
    ^_^
    PS: Your forums may be smaller than those of Gentoo, but that is not necessarily a disadvantage.  There is like a perfect size, I think.  You can be too small OR too big... with bigger forums, it is so much easier for a thread to just get buried if no one can answer it right away, even though someone else might be able to but will never see it because it's already buried.  This happened to me in the Ubuntu forums.  I obviously do not run Ubuntu but posted a question there regarding mtpfs with a particular MP3 player, because I figured the forums were large enough that I'd get at least a few people with the same mp3 player and they could tell me their experiences with the program.  HA!  Instead, I just got 0 replies and it was simply buried.  With forums, bigger isn't *always* better, imo.
    PPS: What is your policy on patching the source code?  For example, GTK+ recently deprecated a few features that TiLP(1 and 2) depends on.  The source code will now not compile.  I made a patch for it to fix it (I was supposed to submit that ebuild two days ago... grah, I really should do it tomorrow!), for otherwise it just gives errors.  If it is TiLp2 you have in the repository, it is literally as simple as adding one line in the source code (and is the fix the developer himself recommended), but Gentoo did not even notice and kept the source code in the tree the same even though it would no longer compile! @_@  This kind of ticked me off, personally, which is why I have to submit that patch tomorrow!  ha ha
    Last edited by violagirl23 (2008-01-24 06:00:10)

  • How do I search the downloaded Java? Platform, Standard Edition 6 API?

    I am a newbie to Java (I had done some limited programming in C ++ years ago). I have downloaded the Java? Platform, Standard Edition 6 API Specification, and can view this in my Firefox browser. How can I search to certain classes in this documentation easily? For instance, if I want to ding out all of the operations available for String or System.out, etc, , is there a way that I can type in System.out, or String somewhere, and get a list of what is available?
    Thanks

    Brian_Rohan wrote:
    Here is the code that I compiled and it worked:Yeah, "args" there isn't part of the API. It's the name of the variable that is the first parameter to the main method defined there.
    The stuff between the parentheses is a list of declarations of local variables that form the parameter list to that method, to put it technically.
    The thing that's part of the API is the class String. In "String[] args", the bit on the left is the type of the variable, and the bit on the right is name of the variable. A name of something you define like that wouldn't be in the API. However, the name of the class String is.
    If you look at the import statements, you'll see if the name "String" is actually shorthand for a class defined elsewhere. There's this:
    import java.util.*;So you can know that "String" is either defined in the java.util package, in the "helloworld" package (which also wouldn't be in the API because you're defining in there using the package keyword), or in java.lang. (The "java.lang" package is automatically imported.)
    You could look in the API docs for java.util.String or java.lang.String to find the class definition. But I'll save you the time by letting you know that it's actually java.lang.String.
    Again I am new at this, what would args.length be?You'll see that the type of the "args" variable is "String[]". That means that it's an array of String objects. (The [] means arrays.) Arrays all have a field called "length". This also is part of the language, not the API, so it would be in a language guide, not the API.
    The value of args.length would depend on how you ran your program. When you run a program on the command line like this:
    java HelloWorldor this:
    java HelloWorld foo bar bazThe java virtual machine takes all the things after the class name and sticks them in an array of String. Then it looks for a static method named "main" in the HelloWorld class, and passes it that array. So in the first case above, args.length would be zero, and in the second case it would be three.
    By the way, when you post code, please wrap it in code tags. Highlight it, then click the "CODE" button above the text input box.
    Edited by: paulcw on Nov 4, 2009 6:35 PM

  • Problem with adding text to a syntax document

    Hello,
    I am trying to write an editor with syntax highlighting option.
    The syntax document works fine but on a slow computer
    after loading a huge document it is impossible to write fluently.
    I think the method highlightKeyword() is not the problem because it highlights still only one line.
    The problem seems to be the rootElement.Has anybody an idea how to make the rootElement faster
    working?
    I also tried to use threads (such as http://ostermiller.org/syntax/editor.html) for inserting text, but then the document is highlighted very slowly.
    Can anybody help me?
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class SyntaxTest extends DefaultStyledDocument
         Element rootElement;
         String wordSeparators = ",:;.()[]{}+-/*%=<>!&|~^@? ";
         Vector keywords = new Vector();;
         SimpleAttributeSet keyword;
         public SyntaxTest()
              rootElement= this.getDefaultRootElement();
              keyword = new SimpleAttributeSet();
              StyleConstants.setForeground(keyword, Color.blue);
              keywords.add( "abstract" );
              keywords.add( "boolean" );
              keywords.add( "break" );
              keywords.add( "byte" );
              keywords.add( "case" );
              keywords.add( "catch" );
              keywords.add( "char" );
              keywords.add( "class" );
              keywords.add( "continue" );
              keywords.add( "default" );
              keywords.add( "do" );
              keywords.add( "double" );
              keywords.add( "else" );
              keywords.add( "extends" );
              keywords.add( "false" );
              keywords.add( "final" );
              keywords.add( "finally" );
              keywords.add( "float" );
              keywords.add( "for" );
              keywords.add( "if" );
              keywords.add( "implements" );
              keywords.add( "import" );
              keywords.add( "instanceof" );
              keywords.add( "int" );
              keywords.add( "interface" );
              keywords.add( "long" );
              keywords.add( "native" );
              keywords.add( "new" );
              keywords.add( "null" );
              keywords.add( "package" );
              keywords.add( "private" );
              keywords.add( "protected" );
              keywords.add( "public" );      
              keywords.add( "return" );
              keywords.add( "short" );
              keywords.add( "static" );
              keywords.add( "super" );
              keywords.add( "switch" );
              keywords.add( "synchronized" );
              keywords.add( "this" );
              keywords.add( "throw" );
              keywords.add( "throws" );
              keywords.add( "true" );
              keywords.add( "try" );
              keywords.add( "void" );
              keywords.add( "volatile" );
              keywords.add( "while" );
         public void insertString(int offset, String str, AttributeSet a) throws BadLocationException
              super.insertString(offset, str, a);
              int startOfLine = rootElement.getElement(rootElement.getElementIndex(offset)).getStartOffset();
              int endOfLine = rootElement.getElement(rootElement.getElementIndex(offset+str.length())).getEndOffset() -1;
              //highlight the changed line
              highlightKeyword(this.getText(0,this.getLength()), startOfLine, endOfLine);
         public void remove(int offset, int length) throws BadLocationException
              super.remove(offset, length);
              int startOfLine = rootElement.getElement(rootElement.getElementIndex(offset)).getStartOffset();
              int endOfLine = rootElement.getElement(rootElement.getElementIndex(offset+length)).getEndOffset() -1;
              //highlight the changed line
              highlightKeyword(this.getText(0,this.getLength()), startOfLine, endOfLine);
         public void highlightKeyword(String content,int startOffset, int endOffset)
              char character;
              int tokenEnd;
              while (startOffset < endOffset)
                   tokenEnd = startOffset;
                   //find next wordSeparator
                   while(tokenEnd < endOffset)
                   character = content.charAt(tokenEnd);
                        if(wordSeparators.indexOf(character) > -1)
                             break;
                        else
                             tokenEnd++;                    
                   //check for keyword
         String token = content.substring(startOffset,tokenEnd).trim();
                        if(keywords.contains(token))
                   this.setCharacterAttributes(startOffset, token.length(), keyword, true);
         startOffset = tokenEnd+1;
         public static void main(String[] args)
              JFrame f = new JFrame();
              JTextPane pane = new JTextPane(new SyntaxTest());
              JScrollPane scrollPane = new JScrollPane(pane);
              f.setContentPane(scrollPane);
              f.setSize(600,400);
              f.setVisible(true);

    I don't think the root element is the problem. Syntax highlighting is just plain slow for a large file. Here is an example, you can use for comparison purposes, that does [url http://www.discoverteenergy.com/files/SyntaxDocument.java]syntax highlighting. It is very slow when loading large files into the text pane, but works reasonably when modifying the contents of the text pane.

  • Java program doubt

    Hello friends,
    what is the use of _ package_ and why only introduced in java ? what is the function of_ static_ keyword.

    The package keyword allows you to create your own packages similar to the current import packages that come with the JDK.
    e.g. import java.swing.*JOptionPane*;
    would import the JOptionPane class from the java.swing package allowing you to utilize the JOptionPane's predefined class and methods
    now in your case, say you want to package x amount of classes for what ever use that is intended (i.e. distribution, modulation, or just separating class for better debugging practice)
    once you package a class you would import it similar to the JOptionPane class:
    import examplePackage.*exampleClass*;
    or
    import examplePackage.*; (for all classes available to the examplePackage class)

  • Netbeans and JavaFX

    I am new to Netbeans and am only using it for the JavaFX integration (IntelliJ user) so I am not sure if I am dealing with my ignorance of Netbeans or some JavaFX idiosyncrasy.
    However, when I try to organize my JavaFX code into package structure (rather than using a single default package) and go to run it I get NoClassDef exceptions on my main class. It looks like netbeans automatically packages up the files into a jar and runs it from a jar. I took a peek inside the generated jar and Netbeans is not maintaining the package structure inside the jar it is just putting all the classes at the root of the jar (hence the NoClassDefs).
    How can I get Netbeans to maintain the package structure inside the jar?
    Does JavaFX use the "package" keyword the same way as Java does?

    Yep, after I was able to get my classes in a package structure (rather than default package) I discovered that.
    I couldn't at first get my classes out of the default package. I am spoiled by IntelliJ which changes/adds package statements when you move classes. Netbeans did not automatically add the package statement when I moved from the default package to a package structure. Nor did it warn me that the classes were missing a package statement and/or the package statement didn't match its package location.

  • Allright, this seems a bit silly.

    Hi, I'm currently in the process of getting Java to run on my computer. However(like everyone), Java seems to have trouble finding the .jar files I'm trying to import.
    Those .jar files ARE in the jblahblah\lib\bin\ext\ directory. The environment variable PATH specifies that same directory. I even went through the trouble of putting the .jar files in the same folder as the program and putting THAT in the path. It still can't find it.
    javac -cp . GUITest.java
    javac -classpath . GUITest.java
    They both give me the same error when I tried them:
    package BreezySwing.jar not found
    package TerminalIO.jar not found
    Why can't Java find these files? I know about the 'package' keyword, but I'm not sure if it pertains to this problem or not, and if it did, I don't know how to use it.

    Well, this is specifically what I have in the program:
    import javax.swing.*;
    import TerminalIO.*;
    import BreezySwing.*;
    public class GUITest extends GBFrame
         private JButton button1, button2;
         private JLabel label;
         public GUITest()
              button1 = addButton("Hello!",1,1,1,1);
              button2 = addButton("Goodbye.",1,2,1,1);
              label = addLabel("click on button plz",2,1,2,1);
         public void buttonClicked(JButton bO)
              if(bO == button1)
                   messageBox("HI!");
              else
                   System.exit(1);
         public static void main(String[] args)
              GUITest theGUI = new GUITest();
              theGUI.setSize(500,500);
              theGUI.setTitle("THIS IS ONLY A DRILL ~~ THIS IS ONLY A DRILL~~");
              theGUI.setVisible(true);
    }The error message I get, specifically(I didn't c+p) is:
    GUITest.java:2: package TerminalIO does not exist
    import TerminalIO.*;
    ^
    GUITest.java:3: package BreezySwing does not exist
    import BreezySwing.*;
    ^

Maybe you are looking for