voidflux
10-10-2004, 03:24 PM
Hello everyone, I have 3 files,
Application1.java
Target.java
Frame1.java
In my target class I have code that will draw a target shape.
In this pattern:
********
*******
******
*****
****
***
**
*
My code works fine, but I want to be able to accept an argument from a command prompt, so I need to get the following:
int size = Integer.parseInt(argv[0])
then i can pass size to my draw function:
Target t = new Target();
t.drawPattern(size);
The probelm is, since this is a windows based program, the main function is located in Application1.java and looks like this:
//Main method
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new Application1();
}
Does anyone know how i'm suppose to access the main argument? If I try to put any code into the main fucntion, it will say,
java.lang.NullPointerException
at lab5.Application1.main(Application1.java:76)
Exception in thread "main"
So how am i suppose to get the main argument if i'm not allowed to put any code in there?
Thanks for listening :D
Application1.java
Target.java
Frame1.java
In my target class I have code that will draw a target shape.
In this pattern:
********
*******
******
*****
****
***
**
*
My code works fine, but I want to be able to accept an argument from a command prompt, so I need to get the following:
int size = Integer.parseInt(argv[0])
then i can pass size to my draw function:
Target t = new Target();
t.drawPattern(size);
The probelm is, since this is a windows based program, the main function is located in Application1.java and looks like this:
//Main method
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new Application1();
}
Does anyone know how i'm suppose to access the main argument? If I try to put any code into the main fucntion, it will say,
java.lang.NullPointerException
at lab5.Application1.main(Application1.java:76)
Exception in thread "main"
So how am i suppose to get the main argument if i'm not allowed to put any code in there?
Thanks for listening :D