Problem with static keyword
I faced Problem while using static keyword in Netbeans 6.5
'static' doesn't exist anymore in JavaFX Script. Instead, put your functions and variable definitions outside of your class. Then they will be script level, which is roughly equivalent to 'static' in Java.
Similar Messages
-
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
VanceIs 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. -
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 -
What is difference when using import statement with static keyword ?
10. package com.sun.scjp;
11. public class Geodetics {
12. public static final double DIAMETER = 12756.32; // kilometers
13. }
Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.)
A. import com.sun.scjp.Geodetics;
public class TerraCarta {
public double halfway()
{ return Geodetics.DIAMETER/2.0; }
B. import static com.sun.scjp.Geodetics;
public class TerraCarta{
public double halfway() { return DIAMETER/2.0; } }
C. import static com.sun.scjp.Geodetics.*;
public class TerraCarta {
public double halfway() { return DIAMETER/2.0; } }
D. package com.sun.scjp;
public class TerraCarta {
public double halfway() { return DIAMETER/2.0; } }
The correct answer is A,C.I understood how A is the answer ,but can anyone explain me about package import using static keyword.The above example can be used as a reference.
Thanks for your consideration.amtidumpti wrote:
10. package com.sun.scjp;
11. public class Geodetics {
12. public static final double DIAMETER = 12756.32; // kilometers
13. }
Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.)
A. import com.sun.scjp.Geodetics;
public class TerraCarta {
public double halfway()
{ return Geodetics.DIAMETER/2.0; }
B. import static com.sun.scjp.Geodetics;
public class TerraCarta{
public double halfway() { return DIAMETER/2.0; } }
C. import static com.sun.scjp.Geodetics.*;
public class TerraCarta {
public double halfway() { return DIAMETER/2.0; } }
D. package com.sun.scjp;
public class TerraCarta {
public double halfway() { return DIAMETER/2.0; } }
The correct answer is A,C.I understood how A is the answer ,but can anyone explain me about package import using static keyword.The above example can be used as a reference.
Thanks for your consideration.here's a link to a small tutorial:
[http://www.deitel.com/articles/java_tutorials/20060211/index.html] -
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-benjiroHello 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) -
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,
EricHi 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 -
Problems with ABAP Keyword Documentation after install Internet Explorer 7
After install Internet Explorer 7 I see left frame with tree in ABAP Keyword Documentation, but don't see right frame.
I find note 857216, but it not approach.
Product Version SAP R/3 ENTERPRISE 47X200
SAP GUI 620 Final Release 6206.6.62.970
Internet Explorer 7.0.5730.11Once the page is opened, try to refresh the page a few times. I have seen this couple of times but just refreshing the same will solve the problem I believe.
Regards
Kathirvel -
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 -
Problem with metadb keyword in profile
I am new to use of mirroring during Jumpstart ( I just upgraded my Jumpstart server to S9-09-04), and can't get past an error that says:
Error in file "Profiles/us087.profile", line 5
metadb c0t0d0s7 size 8192 count 3
ERROR: Invalid keyword
Here is the profile in question:
install_type initial_install
system_type standalone
partitioning explicit
cluster SUNWCXall
metadb c0t0d0s7 size 8192 count 3
metadb c0t2d0s7 size 8192 count 3
filesys mirror:d0 c0t0d0s0 c0t2d0s0 5120 /
filesys mirror:d10 c0t0d0s1 c0t2d0s1 2048 swap
filesys mirror:d20 c0t0d0s3 c0t2d0s3 5120
filesys c0t0d0s4 free
filesys c0t2d0s4 free
What am I missing?
This server was upgraded from Solaris 8 using Live upgrade, are there new packages that I need to install? It should be something simple since I can't seem to find any messages regarding this.<b><font color="red">pmostrom</b></font> <font color="navy">I had this problem but you need to verify which version of check you are using. I initially tried to use metadb with version 1.64 but this failed with your error.
I then found a copy of 1.65 on a 4/04 CD under Misc which will accept metadb as a keyword. There are other issues with this version and you should look for a newer version than this.</font> -
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... -
Constructor problem with super keyword
When I try to compile this class, I get 1 error:
C:\Program Files\Xinox Software\JCreatorV3\MyProjects\FixedDiameterCircle.java:6: cannot resolve symbol
symbol : constructor CircleGUI (int)
location: class CircleGUI
super(100);
^
1 error
class FixedDiameterCircle extends CircleGUI
FixedDiameterCircle()
super(100);
}//end FixedDiameterCircle()
public void setDiameter(int d)
}//end class FixedDiameterCircle
---------Here's the CircleGUI.java-------
import javax.swing.*; //import Swing components
import java.awt.*; //import awt components
import java.awt.event.*; //import event handlers
public class CircleGUI implements ActionListener
JTextField diameter = new JTextField(3); //text field for first name
JTextField color = new JTextField(5); //text field for last name
JButton button = new JButton("Draw"); //update button
JPanel panel = new JPanel(); //panel for frame content pane
JFrame frame = new JFrame("Draw"); //frame for window + title
public CircleGUI()
panel.add(new JLabel("Diameter")); //add a label to panel
panel.add(diameter); //add first to panel
panel.add(new JLabel("Color")); //add another label to panel
panel.add(color); //add a last to panel
button.addActionListener(this); //add a click listener to button
panel.add(button); //add button to panel
frame.setContentPane(panel); //set panel as frame's content
frame.setSize(120, 120); //set frame size (width, height)
frame.setVisible(true); //make frame visible
}//end CircleGUI()
public void actionPerformed(ActionEvent e)//executed when button is clicked
int d = Integer.parseInt(diameter.getText()); //get diameter
Circle circle; //declare Circle variable
if(color.getText().length() == 0) //if no color entered in field
{ //use JColorChooser below
Color rgb = JColorChooser.showDialog(frame, "Choose a Color", null);
if(rgb != null) //if Color rgb chosen
circle = new Circle(d,rgb); //instantiate Circle from Color
}//end if(color...
else
String c = color.getText(); //get color String
circle = new Circle(d,c); //instantiate Circle from String
}//end else
}//end actionPerformed()
public static void main(String[] args) //main method
CircleGUI cGUI = new CircleGUI(); //instantiate CircleGUI
}//end main()
}//end class CircleGUI
What's the problem?CircleGUI does not have a constructor that takes an int. You need to either add this to CircleGui:public CircleGui(int diameter) { /* do stuff */ } or just cal super() instead of super(int). Which one is better is left as an exercise for the reader.
-
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,
AlesHi 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
Maybe you are looking for
-
Help please! Imac won't start and running out of ideas
Help! My imac G4 Flat Panel running tiger won't boot or go beyond the grey screen, here's what happened, I went away on holiday for ten days and unplugged it, on return it worked fine for the first few goes however after leaving it with alot of photo
-
Powershell script to Get members of AD group members with first, last, email address
I'm running a powershell script to retrieve AD users from a specific AD group and pipe specific attributes to a csv file. The script is working perfectly except for one detail. I want the script to ignore any users who have a null value in any of the
-
60i (DV) to 24p Tutorial
Hi, I was wondering if anybody can help me converting 60i video to 24p wiht compressor 2. A step by step process would be greatly appreciated. thank you
-
HT204291 My AirPlay mirroring is grainy.
My AirPlay mirroring was working perfectly and now any movement pixelates and looks very grainy. I can't use it to watch video anymore. I have a 30+Mbps DSL and a new MacBook Pro with plenty of power. Any reason this suddenly doesn't flow well? It ev
-
Is it possible to make a jdialog modal only to its parent?
Hi, I have a jpanel, which has two jdialog children....one of them is modal, however, i want the modal one to be able to access the other child, but it doesn't seem as if this is possible. anyone have any ideas? thanks!