ExceptionInInitializerError: problems with static vars...

Hi!
I got an Env class.
It has many static variables:
public static LogFile log=new LogFile("log.log");
....and other LogFiles, IniFiles, Connection, etc.
I dont want to send this vars via parameters to other objects...
I want to handle the logs globally.
So, when I try to call the Env.log.addline("...") from other objects then it causes an ExceptionInInitializerError....(and NullPOinterException)
Why? I think its a simple thing for you, but I'm new in Java developing.
Please help me!
Is there other way to declare global variables, that can reached by any other class?

Is there other way to declare global variables, that can reached by any other class?No, you're doing it correctly by what you have posted here - there is something else you're coding incorrectly.
Please post a short, concise, executable example of what you're trying to do. This does not have to be the actual code you are using. Write a small example that demonstrates your intent, and only that. Wrap the code in a class and give it a main method that runs it - if we can just copy and paste the code into a text file, compile it and run it without any changes, then we can be sure that we haven't made incorrect assumptions about how you are using it.
Post your code between [code] and [/code] tags as described in Formatting Help on the message entry page. Cut and paste the code, rather than re-typing it (re-typing often introduces subtle errors that make your problem difficult to troubleshoot). Please preview your post when posting code.

Similar Messages

  • Problem with static vars of SQLJ java stored procedure

    Hi,
    When I'm calling a PL/SQL stored procedure that call a Java stored procedure from another Java stored procedure, the second call to the Java stored procedure does not see the first Java stored procedure static variables.
    Why is that?
    Can I configure it to work otherwise so all the Java stored procedure calls in this session will share the same static variables?
    Thanks

    Hi:
    Remove your ; at the end of the sql string.
    String sql = "SELECT VERSION_OFA FROM XX_PARAMETERS";
    I don't know why JDev accept the ; at the end of string in a prepare statement but AFAIK its not legal.
    If your are using the SQL pane of JDev may be the tool strip the ; for you.
    Best regards, Marcelo.

  • When installed JDK but I have problem with System vars may install bundle

    When installed JDK but I have problem with System vars may install bundle [netbeans&JDK] WITHOUT UNISTALLING initial JDK or needed uninstall first ?

    With the word 'automatically', yes you do need pulseaudio. I'm sure you could cook up some udev or related rule to do that in Alsa, but pulseaudio would be easier.

  • Problem with static and nonstatic objects in same code?

    Hi everyone, I am working on a project and I kept running into an odd problem where my code would compile but when I went to run the code I would get an exception. I finally narrowed my problem down to a small fragment. Here is an example.
    class Mut{
    static Mut Fido = new Mut();
    Mut Sammy = new Mut();
    public static void main(String args[]){
    This piece of code will compile but when I run it on an WindowsXP machine the JRE tells me there is an exception at line 3. If I change the code to this:
    class Mut{
    static Mut Fido = new Mut();
    static Mut Sammy = new Mut();
    public static void main(String args[]){
    The code runs fine without any problems. My question is: why can't I create a static object and a nonstatic object in the same class? Is this a certain feature of JAVA I don't understand or is this a blackbox problem with XP? Any help is appreciated. Thanks
    Vance

    Is the exception stack trace what is displayed in the command-line window? If it is here is what is displayed(This is a lot):
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    at Mut.<init>(Mut.java:3)
    C:\>
    I don't know if this is everything because the winow won't let me scroll back up to where I enterd "java Mut"
    Hope this helps.
    Message was edited by: Vance
    cell@tech

  • Problem with static display...

    Hi All,
    I have a problem with my computer displaying a static screen... See model and OS below.
    Sometimes when I am booting up, the screen will display a static-like display. This happens only once in a great while. Sometimes it will happen when waking from sleep. Recently however, it has happened while using the computer right in the middle of doing something...! So I unplugged the monitor connection and plugged it back in... voila! The computer screen comes back! One thing I do know is that the computer is operating behind the static. Just that the image is not displaying what it is supposed to display.
    I've run AHT and it finds nothing. Would this be a graphics card problem (my guess)? Or other? I just read this thread...
    http://discussions.apple.com/thread.jspa?threadID=1947029&tstart=0
    ... and they have found no solution either. Not sure if it's the same problem over several versions of OSX and graphic cards, which makes me think it could be a software problem.
    An image of my screen with all the static can be found here:
    http://i276.photobucket.com/albums/kk19/wanoyee/DSCF2445.jpg
    This is on a 27" Dell display.
    Does anyone know if this is a software issue or hardware issue? Fixes? Anyone else with this problem?
    Thanks for any help.

    Display card is stock Radeon ATI 5770. I'm using a single DVI cable connected directly to the graphics card using the DVI port. No other adapters/converters. Snowy display seems to happen more often lately.
    *This from my Mac...*
    ATI Radeon HD 5770:
    Chipset Model: ATI Radeon HD 5770
    Type: GPU
    Bus: PCIe
    Slot: Slot-1
    PCIe Lane Width: x16
    VRAM (Total): 1024 MB
    Vendor: ATI (0x1002)
    Device ID: 0x68b8
    Revision ID: 0x0000
    ROM Revision: 113-C0160C-155
    EFI Driver Version: 01.00.436
    Displays:
    DELL 2709W:
    Resolution: 1920 x 1200 @ 60 Hz
    Pixel Depth: 32-Bit Color (ARGB8888)
    Main Display: Yes
    Mirror: Off
    Online: Yes
    Rotation: Supported
    Display Connector:
    Status: No Display Connected
    Display Connector:
    Status: No Display Connected
    Also:
    ATI Radeon HD 5770:
    Name: ATY,Hoolock
    Type: display
    Driver Installed: Yes
    Bus: PCI
    Slot: Slot-1
    Vendor ID: 0x1002
    Device ID: 0x68b8
    Subsystem Vendor ID: 0x106b
    Subsystem ID: 0x00cf
    Revision ID: 0x0000
    Link Width: x16
    Link Speed: 5.0 GT/s

  • Problems with Static and non-static stuff

    Right now I am trying to work on a RPG and trying to make it all using classes instead of having a Applet run everything and want to call Methods to make / remove the buttons here is the Method I'm dealing with
        public void placeButtons()
            attackBtn.setBounds(200,700,75,25);
            defendBtn.setBounds(200,725,75,25);
            magicBtn.setBounds(275,700,75,25);
            itemBtn.setBounds(275,725,75,25);
            game.add(attackBtn);   // Here is where I am having the problem (non-static method add(java.awt.Component) cannot be referenced from a static context)
            attackBtn.addActionListener(this);
        }Normally I would be making all my buttons in my main class but I want to know if I can make them in a separate class and load them in my main class so I can shorten my code by a ton.

    Generally speaking: Yes: you are only limited by your ingenuity and knowledge.
    //call from other class
    MyButtonClass mbc = new MyButtonClass();
    MyPanel p = new MyPanel();
    p.add(mbc.getMyMainButton());
    //what everAlthough I would think that it may be better to get your entire Frame back for display or a panel... It just seems like it's going to be awkward to work with unless you're making some kind of button generator or something, but then it's your app and from your description, the code given should illustrate a way of getting to the answer you seek.

  • Problems with static and this

    Hello i am implementing a listener and i try to invoke the listener=this as planned. I am having problems because my method is static and it is so because i need to call that method in my main!
    <code>
         public static void add2hash(String url,ComObject com)
              com= new ComObject(urlPool);
              i++;
              cl = Hashtest;// what to do with this?<-- PROBLEM!!!!
              //new ComObject(); this?
              co.addComListener(cl);
              System.out.println("Let's start!\n ComObject Listening to itself: ");
              String host=str2host(url);
              ht.put(host,co);
              //co.checkStatus();
              //return co.getIs();
    </code>

    RE: tschodt
    I'll start with a comment of agreement :)
    You are having problems because you have yet to grasp the concept of OO.An insightful comment, this seems apparent. :)
    BTW, this has nothing to do with native methods, snip
    Well... just a minor point... but it would appear his code is dealing with some Win32 natives, either from JacobGen or J-Integra, since he is using a ComObject object (I could be way off base as I don't see any import statements.) Maybe follow-up questions in this thread could be relating to the API functionality of some of the classes he's using? :)
    RE: original poster
    If you do want to call this directly from main, take note of the name of the class in which this is defined. Then import the package and class into the class containing your main method (if your main isn't in the same package as the class containing add2hash). Then call OtherClass.add2hash(); from main.
    On another note, in order for us to understand your comment indicating a problem with the ComObject assignment, we'd need to know where you got that object -- maybe show us your import statements? :)
    Regards,
    Sean
    /watchlists topic

  • Problems with static IP from TP-Link Access Point

    Hello Guys!
    I'm new with Apple - i got a Macbook Pro Mid 2012 since 2 weeks.
    Everythings running fine and im really happy with the Macbook - except of the Wifi.
    I have the problem that the internet connection is just working temporarily, sometimes its just working for 1 minute, then its just stopping. im still connected to the wifi, no connection abortion. websites are just not getting loaded or just half.
    i cant find a solution for it, so please help me
    I connected a TP-Link tl-wa801nd with a ethernet cable to our companys network - creating a wifi network access point with which i can connect to with my devices (Macbook Pro, iphone and Win7 PC)
    I have to give my devices a static ip, when i want to connect with it:
    IP: 192.168.0.151 - 192.168.0.199
    Subnet mask: 255.255.255.0
    Router and DNS: 192.168.0.1
    These preferences are working perfect with the iphone, Win 7-PCs and some friends Android or BB phones. No problems.
    Except of the Macbook pro:
    I got the newest Mavericks on it and the same network preferences (except of a ascending ip address and the search domain 192.168.0.1)
    But like i said above - network is just working temporarily, sometimes for 1 minute, then stopping for 10 minutes... The problem must be the macbook, because every other devices is working fine.
    Thank for your helping answers
    banana-benjiro

    Hello banana-benjiro,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    Safari 5.0.1 or later: Slow or partial webpage loading, or webpage cannot be found
    http://support.apple.com/kb/ts3408
    Best of luck,
    Mario

  • Any help with this program (a bit of a problem with static references)

    Can anyone give me any suggestions for fixing this code:
    package vivarium;
    import javax.swing.JApplet;
    import javax.swing.JFrame;
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    public class Render extends java.applet.Applet {
         static Animal[] animal_array_world;
         public static void main(String s[])  {
              JFrame frame = null;
              Graphics g = null;
              int[][] grassarray = new int[16][16];
              createapplet(frame);
              Render r = new Render();
              r.rendergrass(g, grassarray);
              frame.paint(g);
              //createcreatures(20);
              //live();
         public void rendergrass(Graphics g, int[][] array) {
              URL codebase = getCodeBase();
              java.awt.Image grass =  getImage(codebase, "grass.JPG");
              java.awt.Image deadgrass =  getImage(codebase, "deadgrass.JPG");
              for(int i = 0; i < 16; i++)
                   for(int j = 0; j < 16; j++) {
                        int y = (i * 16);
                        int x = (j * 16);
                   if(array[i][j] == 0) {
                        drawimage(g, grass, y, x);
                   else
                        drawimage(g, deadgrass, y, x);
         public  void drawimage(Graphics g, java.awt.Image img, int y, int x) {
              g.drawImage(img, y, x, this);
         public static void createapplet(JFrame frame) {
              frame = new JFrame();
              frame.setTitle("Kirby's Vivarium Demo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JApplet applet = new RenderApplet();
              applet.init();
              frame.getContentPane().add(applet);
              frame.pack();
              frame.setVisible(true);
         //this creates an array of creatures
         public static void createcreatures(int x) {
              animal_array_world = new Animal[x*2];
         //this will than act on that
         public static void live() {
              while(true) {
              int i = 0;
              while(i != animal_array_world.length - 1) {
                   animal_array_world.live(animal_array_world);
    The problem seems to be with
    URL codebase = getCodeBase();
    java.awt.Image grass =  getImage(codebase, "grass.JPG");
    java.awt.Image deadgrass =  getImage(codebase, but I do not get how. This is a non-static field, but no matter what I do it seems to complain in some manner. Does anyone have any suggestions? Thanks!

    Exception in thread "main" java.lang.NullPointerException
         at java.applet.Applet.getCodeBase(Unknown Source)
         at vivarium.Render.rendergrass(Render.java:29)
         at vivarium.Render.main(Render.java:20)I get this despite whether I put the getCodeBase part in a method, the main or the initialization block.
    Heres line 29: URL codebase = getCodeBase();This is called within my nonstatic method rendergrass.
    And heres line 20: r.rendergrass(g, grassarray);(Where r is a new Render class object)

  • Problems with static member variables WAS: Why is the static initializer instantiating my class?!

    Hi,
    I have been hunting down a NullPointerException for half a day to come to
    the following conclusion.
    My constructor calls a method which uses static variables. Since an intance
    of my class is created in the static block when the class is loaded, those
    statics are probably not fully initialized yet and the constructor called
    from the static block has those null pointer problems.
    I've considered moving the initialization of the static variables from the
    declaration to the static block. But your code is inserted BEFORE any other
    code. Therefore not solving my problem.
    Two questions:
    1) what would be a solution to my problem? How can I make sure my static
    variables are initialized before the enhancer generated code in the static
    block calls my constructor? Short of decompiling, changing the code and
    recompiling.
    2) Why is the enhancing code inserted at the beginning of the static block
    and not at the end? The enhancements would be more transparent that way if
    the static variables are initialized in the static block.
    Thanks,
    Eric

    Hi Eric,
    JDO calls the no-args constructor. Your application should regard this constructor as belonging
    primarily to JDO. For example, you would not want to initialize persistent fields to nondefault
    values since that effort is wasted by JDO's later initilization to persistent values. Typically all
    you want to initialize in the no-args constructor are the transactional and unmanaged fields. This
    rule means that you need initialization after construction if your application uses the no-args
    constructor and wants persistent fields initialized. On the other hand, if your application really
    uses constructors with arguments, and you're initializing persistent fields in the no-args
    constructor either unintentionally through field initializers or intentionally as a matter of
    consistency, you will find treating the no-args constructor differently helpful.
    On the other hand, if Kodo puts its static initializer code first as you report, then it is a bug.
    Spec Section 20.16: "The generated static initialization code is placed after any user-defined
    static initialization code."
    David Ezzio
    Eric Borremans wrote:
    >
    Hi,
    I have been hunting down a NullPointerException for half a day to come to
    the following conclusion.
    My constructor calls a method which uses static variables. Since an intance
    of my class is created in the static block when the class is loaded, those
    statics are probably not fully initialized yet and the constructor called
    from the static block has those null pointer problems.
    I've considered moving the initialization of the static variables from the
    declaration to the static block. But your code is inserted BEFORE any other
    code. Therefore not solving my problem.
    Two questions:
    1) what would be a solution to my problem? How can I make sure my static
    variables are initialized before the enhancer generated code in the static
    block calls my constructor? Short of decompiling, changing the code and
    recompiling.
    2) Why is the enhancing code inserted at the beginning of the static block
    and not at the end? The enhancements would be more transparent that way if
    the static variables are initialized in the static block.
    Thanks,
    Eric

  • Having Problem With "static" When Running a Stand Alone Java Class

    I have a Java class that recursively builds a 'tree' . This Java class works as I expected without problem. I am able to write out this 'tree" to the console "line by line" with proper indentation.
    The problem occurs when I try to iterate through this 'tree' in the public static void main(String[] arg) method -- Each line in the tree is an Array. And I have to declare this Array (called titleArray in my code) non-static; otherwise, I end up with picking up the very last line of my hard-coded data.
    Besides, I also have to declare the List (called recursiveTextArray in my code) non-static; otherwise, I end up with picking up the first Array that I ever build and run into endless iterations till the heap size is exhausted. Note that each element of that List is an Array object.
    Then, this non-static Array and this non-static List cannot be accessed in the public static void main(String[] arg) method.
    What should I do?
    Here is my code that works without problem (the one I do not access the 'titleArray' in the main(String[] arg) method):
    import java.util.Iterator;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Date;
    import java.awt.Color;
    import com.aspose.words.*;
    public class OplanPhase
         public static void main( String[] args)
              OplanPhase root = new OplanPhase( "", "Oplan 50XX - Phase I" );
              OplanPhase objective1 = new OplanPhase( "OO-3.1", "Destroy enemy conventional ground forces" );
              OplanPhase objective2 = new OplanPhase( "OO-3.2", "Destroy enemy conventional air forces" );          
              OplanPhase objective3 = new OplanPhase( "OO-3.3", "Destroy enemy conventional naval forces" );
              OplanPhase objective4 = new OplanPhase( "OO-3.4", "Influence opposition groups within enemy areas to support friendly forces" );
              OplanPhase effect1 = new OplanPhase( "TgtObj-3.1", "Locate, identify, and destroy key enemy C2 nodes" );
              OplanPhase effect2 = new OplanPhase( "TgtObj-3.2", "Locate, identify, and destroy key enemy C2 nodes" );          
              OplanPhase effect3 = new OplanPhase( "CFSOCC-3.2", "influence enemy opposition groups to support friendly forces campaign objectives" );
              OplanPhase effect4 = new OplanPhase( "JFMECC-3.3", "Destroy SLOC interdiction vessels" );
              OplanPhase effect5 = new OplanPhase( "CFSOCC-3.4", "Influence enemy opposition groups to support friendly forces campaign objectives" );     
              OplanPhase moe1 = new OplanPhase( "MOE-TO-3.1", "Conduct surveillance to locate and identify key enemy C2 nodes" );
              OplanPhase moe2 = new OplanPhase( "MOE-JFSOC-3.1", "Degree of cooperative effort with area opposition groups" );
              OplanPhase moe3 = new OplanPhase( "MOE-JFSOC-3.2", "Number of combined missions successfully completed with opposition groups" );
              OplanPhase moe4 = new OplanPhase( "MOE-JFSOC-3.3", "Number of combined missions successfully completed with opposition groups" );
              OplanPhase task1 = new OplanPhase( "TASK-TO-3.1", "Destroy key enemy C2 nodes" );
              OplanPhase task2 = new OplanPhase( "TASK-TO-3.2", "Conduct surveillance to locate and identify key enemy C2 nodes" );
              OplanPhase task3 = new OplanPhase( "TASK-TO-3.3", "Destroy key enemy C2 nodes" );
              OplanPhase task4 = new OplanPhase( "TASK-JFSOC-3.1", "Degree of cooperative effort with area opposition groups" );
              root.addSubLevel( objective1 );
              root.addSubLevel( objective2 );
              root.addSubLevel( objective3 );
              root.addSubLevel( objective4 );
              objective1.addSubLevel( effect1 );
              objective2.addSubLevel( effect2 );
              objective2.addSubLevel( effect3 );
              objective3.addSubLevel( effect4 );
              objective4.addSubLevel( effect5 );
              effect1.addSubLevel( moe1 );
              effect1.addSubLevel( task1 );
              effect2.addSubLevel( task2 );
              effect2.addSubLevel( task3 );
              effect3.addSubLevel( moe2 );
              effect3.addSubLevel( moe3 );
              effect5.addSubLevel( task4 );
              effect5.addSubLevel( moe4 );
              root.outputAllWithIndentation( 0 );
         private String[] titleArray = { "", "", "" };
         private int indentation = 0;
         private List<OplanPhase> subLevels = new ArrayList<OplanPhase>();
         private List recursiveTextArray = new ArrayList();
         public OplanPhase( String foo, String bar )
              titleArray[1] = foo;
              titleArray[2] = bar;
         public void addSubLevel( OplanPhase op )
              subLevels.add( op );
         public void outputAllWithIndentation( int level )
              indentation = level;
              titleArray[0] = indentString( indentation );
             System.out.println( titleArray[0] + "[" + titleArray[1] + "] " + titleArray[2] );
             recursiveTextArray.add( titleArray );
              for ( int i = 0; i < subLevels.size(); i++ )
                   ( ( OplanPhase )subLevels.get( i ) ).outputAllWithIndentation( level + 1 );
         private static String indentString( int count )
              String blank = "";
              for ( int i = 0; i < count; i++ )
                   blank = blank.concat( "   " );
              return blank;
    }And the code below gives me the static and non-static problem:
    import java.util.Iterator;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Date;
    import java.awt.Color;
    import com.aspose.words.*;
    public class OplanPhase
         public static void main( String[] args)
              OplanPhase root = new OplanPhase( "", "Oplan 50XX - Phase I" );
              OplanPhase objective1 = new OplanPhase( "OO-3.1", "Destroy enemy conventional ground forces" );
              OplanPhase objective2 = new OplanPhase( "OO-3.2", "Destroy enemy conventional air forces" );          
              OplanPhase objective3 = new OplanPhase( "OO-3.3", "Destroy enemy conventional naval forces" );
              OplanPhase objective4 = new OplanPhase( "OO-3.4", "Influence opposition groups within enemy areas to support friendly forces" );
              OplanPhase effect1 = new OplanPhase( "TgtObj-3.1", "Locate, identify, and destroy key enemy C2 nodes" );
              OplanPhase effect2 = new OplanPhase( "TgtObj-3.2", "Locate, identify, and destroy key enemy C2 nodes" );          
              OplanPhase effect3 = new OplanPhase( "CFSOCC-3.2", "influence enemy opposition groups to support friendly forces campaign objectives" );
              OplanPhase effect4 = new OplanPhase( "JFMECC-3.3", "Destroy SLOC interdiction vessels" );
              OplanPhase effect5 = new OplanPhase( "CFSOCC-3.4", "Influence enemy opposition groups to support friendly forces campaign objectives" );     
              OplanPhase moe1 = new OplanPhase( "MOE-TO-3.1", "Conduct surveillance to locate and identify key enemy C2 nodes" );
              OplanPhase moe2 = new OplanPhase( "MOE-JFSOC-3.1", "Degree of cooperative effort with area opposition groups" );
              OplanPhase moe3 = new OplanPhase( "MOE-JFSOC-3.2", "Number of combined missions successfully completed with opposition groups" );
              OplanPhase moe4 = new OplanPhase( "MOE-JFSOC-3.3", "Number of combined missions successfully completed with opposition groups" );
              OplanPhase task1 = new OplanPhase( "TASK-TO-3.1", "Destroy key enemy C2 nodes" );
              OplanPhase task2 = new OplanPhase( "TASK-TO-3.2", "Conduct surveillance to locate and identify key enemy C2 nodes" );
              OplanPhase task3 = new OplanPhase( "TASK-TO-3.3", "Destroy key enemy C2 nodes" );
              OplanPhase task4 = new OplanPhase( "TASK-JFSOC-3.1", "Degree of cooperative effort with area opposition groups" );
              root.addSubLevel( objective1 );
              root.addSubLevel( objective2 );
              root.addSubLevel( objective3 );
              root.addSubLevel( objective4 );
              objective1.addSubLevel( effect1 );
              objective2.addSubLevel( effect2 );
              objective2.addSubLevel( effect3 );
              objective3.addSubLevel( effect4 );
              objective4.addSubLevel( effect5 );
              effect1.addSubLevel( moe1 );
              effect1.addSubLevel( task1 );
              effect2.addSubLevel( task2 );
              effect2.addSubLevel( task3 );
              effect3.addSubLevel( moe2 );
              effect3.addSubLevel( moe3 );
              effect5.addSubLevel( task4 );
              effect5.addSubLevel( moe4 );
              root.outputAllWithIndentation( 0 );
              try
                  Iterator it = recursiveTextArray.iterator(); //compilation error
                  while ( it.hasNext() )
                       for ( int i=0; i<titleArray.length; i++ ) //compilation error
                            if ( i == 0 )
                                 System.out.println( titleArray[0] ); //compilation error
                            } else if ( i == 1 )
                                 System.out.println( "[" + titleArray[1] + "] " ); //compilation error                             
                            } else if ( i == 2 )
                                 System.out.println( titleArray[2] ); //compilation error
              } catch (Exception e)
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         private String[] titleArray = { "", "", "" };
         private int indentation = 0;
         private List<OplanPhase> subLevels = new ArrayList<OplanPhase>();
         private List recursiveTextArray = new ArrayList();
         public OplanPhase( String foo, String bar )
              titleArray[1] = foo;
              titleArray[2] = bar;
         public void addSubLevel( OplanPhase op )
              subLevels.add( op );
         public void outputAllWithIndentation( int level )
              indentation = level;
              titleArray[0] = indentString( indentation );
             System.out.println( titleArray[0] + "[" + titleArray[1] + "] " + titleArray[2] );
             recursiveTextArray.add( titleArray );
              for ( int i = 0; i < subLevels.size(); i++ )
                   ( ( OplanPhase )subLevels.get( i ) ).outputAllWithIndentation( level + 1 );
         private static String indentString( int count )
              String blank = "";
              for ( int i = 0; i < count; i++ )
                   blank = blank.concat( "   " );
              return blank;
    }

    What should I do?If you feel you need to cross-post, you should have the courtesy to provide a
    link to the other post/s.
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=1&t=016129

  • Problems with partion /var

    Hello,
    I have solaris 10 installed on an Virtual Machine and suddenly partition /var was not accessible.
    A reboot solved the problem but after about 12 hours the problem reappeared.
    Also with fdisk I have done:
    umount /var
    fsck /var
    ** /dev/rdsk/c1t0d0s3
    ** Last Mounted on /var
    ** Phase 1 - Check Blocks and Sizes
    ** Phase 2 - Check Pathnames
    ** Phase 3a - Check Connectivity
    ** Phase 3b - Verify Shadows/ACLs
    ** Phase 4 - Check Reference Counts
    ** Phase 5 - Check Cylinder Groups
    CORRECT BAD CG SUMMARIES? y
    CORRECTED SUMMARY FOR CG 0
    FRAG BITMAP WRONG
    FIX? y
    CORRECT GLOBAL SUMMARY
    SALVAGE? y
    Log was discarded, updating cyl groups
    4490 files, 364788 used, 25455971 free (4611 frags, 3181420 blocks, 0.0% fragmentation)
    ***** FILE SYSTEM WAS MODIFIED *****
    I also have found in /var/adm/messages :
    scsi: [ID 107833 kern.warning] WARNING: /pci@0,0/pci1000,30@10 (mpt0): right before the problem appeared
    Can I do something so the problem doesn't appear any more?
    null

    Hello,
    I have solaris 10 installed on an Virtual Machine and suddenly partition /var was not accessible.
    A reboot solved the problem but after about 12 hours the problem reappeared.
    Also with fdisk I have done:
    umount /var
    fsck /var
    ** /dev/rdsk/c1t0d0s3
    ** Last Mounted on /var
    ** Phase 1 - Check Blocks and Sizes
    ** Phase 2 - Check Pathnames
    ** Phase 3a - Check Connectivity
    ** Phase 3b - Verify Shadows/ACLs
    ** Phase 4 - Check Reference Counts
    ** Phase 5 - Check Cylinder Groups
    CORRECT BAD CG SUMMARIES? y
    CORRECTED SUMMARY FOR CG 0
    FRAG BITMAP WRONG
    FIX? y
    CORRECT GLOBAL SUMMARY
    SALVAGE? y
    Log was discarded, updating cyl groups
    4490 files, 364788 used, 25455971 free (4611 frags, 3181420 blocks, 0.0% fragmentation)
    ***** FILE SYSTEM WAS MODIFIED *****
    I also have found in /var/adm/messages :
    scsi: [ID 107833 kern.warning] WARNING: /pci@0,0/pci1000,30@10 (mpt0): right before the problem appeared
    Can I do something so the problem doesn't appear any more?
    null

  • Problem with static

    Hi Guys,
    In my page i declared ObjectListDataProvider object bound to table component
    in order to prevent the this object get re instatiated everytime the page postBack i declared it as static.
    The question is will it create a problem if few concurrent user assessing the same page and perform some changes to the table such as edit / delete data which will change the state of my ObjectListDataProvider object.

    Check your electrical power wiring. Either the ground connections is bad (the round prong on the wall plug) or the hot and neutral are inverted (neutral is the wide blade). Home Depot, et. al., sell power testers with LEDs that can check this out quickly.
    If you aren't using the three-prong plugs and the two-prong plugs aren't polarized (wide blade/narrow blade), try rotating the plugs on the connections until the static shock disappears.
    Or, get a professional electrician to certify the installation...

  • A problem with Static/RSS ticker

    Hello everyone!
    I have a test lab set up (DMM 5.1 and DMP-4305G, license is OK).
    I made a few presentations with Cisco Digital Media Designer that included video, text ticker and RSS ticker.
    Video works fine.
    Static text ticker almost works perfect, only i can't change the effect of text (it's alwys fadeing even if i change it to left/fight scroll).
    RSS feeds are visible in Cisco Digital Media Designer and seems to work, but when i play it on DMP, the box with rss feed is blank.
    Please, i need some advice, i tried everything i could think of...
    Best Regards,
    Ales

    Hi Aurelio,
    Thank you for your post!
    This is the rss link i am using:
    http://www.rtvslo.si/slovenija/rss
    As i said link appears to work in  Digital Media Designer.
    When scheduling the presentation to DMP i have no result.
    I tried different links. This for instance link works perfect-> http://newsrss.bbc.co.uk/rss/newsonline_world_edition/europe/rss.xml
    i also copied the source code of bbcRSS and modified it (it is attached to this post) and put it on my web server, checked it with explorer - it works;
    on Digital Media Designer the link is not reachable, please advise.
    What could be the issue? Character coding maybe?
    ( i also noticed by using static ticker that DMP-4305 can't show slovenian special characters => š č ć ž )
    Does DMP-4305 / Digital Media Designer support different character coding?
    Thanks again for you help,
    Cheers!
    Ales

  • Windows Vista 32 Bit - Problems with Static Sounds

    Hey Guys,
    I dled the latest version of iTunes (7.1) and I am hearing static noises over all my mp3s. Recent upgrade to Vista 32 Bit

    I'm having the exact same problem. I-Tunes and everything worked fine in XP. After the install Vista 32 bit (clean install) my audio clicks and has static only in I-Tunes playback. It may be related to the Sound Blaster X-Fi audio driver.

Maybe you are looking for

  • Error while creating physical inventory document with zero count

    Hi, I am trying to create a physical inventory document for a material that has zero stock and that is not batch managed but I am geting an error as below. "Item 001: No batches that can be included in phys. inv. exist.(Message no. M7701)" This error

  • Some websites images are not loading properly

    <i>Locking duplicate thread.<br>Please continue here: [[/questions/1056687]]</i> It doesn't happen on all websites just some

  • Raw workflow in Aperture 3

    I just switched to shooting raw. I'm trying to figure out how to export my raw files after I've tweaked them in Aperture 3. When I export masters, I get the raw version but not the changes. When I export versions, they're jpegs. I'd like to be able t

  • Unable to post depreciation.

    Have configured Korea - AA. In AFAB doc is generated in AA for depreciation, but unable to post in FI System is prompting " Enter Section Code".                                                                                 Message class Message no.

  • Please Help.Patch Available?

    Hi,I just got an i pod nana and do not have the suficient windows version. I am using Windows ME and i know it ***** but i do not have suficient funds for a new computer at the time. I was wondering if there was some kind of patch out there that will