Hey to all!
I may be doing something really stupid here but I can't see what it is at the moment (9 hours of Java has pretty much fried my brain!).
Basically, when I run the program i'm either typing in the command prompt:
java MyProgram
or
java MyProgram text
The problem occurs when the second one is executed. Although it detects that an arguement has been passed, the if statement fails to go to the TRUE block. Can anyone spot the problem?
Btw, the code "System.out.println(args[0]);" does actually print "text" to the command prompt.
I appreciate any advice!
Cheers,
Rich
I may be doing something really stupid here but I can't see what it is at the moment (9 hours of Java has pretty much fried my brain!).
Basically, when I run the program i'm either typing in the command prompt:
java MyProgram
or
java MyProgram text
The problem occurs when the second one is executed. Although it detects that an arguement has been passed, the if statement fails to go to the TRUE block. Can anyone spot the problem?
Code:
public class MyProgram extends JFrame
{
public static void main(String[] args)
{
String version = "gui";
if (args.length > 0)
{
System.out.println(args[0]);
[B]if(args[0]=="text")[/B]
{
version = "text";
System.out.println("Launching text version...");
}
else
System.out.println("Launching GUI version...");
}
else
System.out.println("Launching GUI version...");
etc etc...
Btw, the code "System.out.println(args[0]);" does actually print "text" to the command prompt.
I appreciate any advice!
Cheers,
Rich