« first day (2 days earlier)      last day (15 days later) » 

00:00
ok great, so can you open the file from the command line by running javaw.exe -jar "C:\...\mjar.jar" "C:\...\file.myext"
?
ok, then the problem is definitely in your Java code.
can you describe what your main method is doing step by step?
i'm a java programmer btw
go on
well yes, more like what is it doing with args[0]?
um it's always (String[] args) < this is the syntax
ok wait, when you say "when I open up a file from the application" do you mean in your Java app, you click File > Open, and choose a file from the Open dialog?
Ok now, what I want to you to tell me is, how does the File > Open command handle the whole "open the file and display its contents" procedure?
what does the userFile variable hold?
Ok, now, here's the thing. When you click File > Open and choose a file, the filename gets stored as a String in the userFile variable. right?
This is what you have to do. In the main method, set the userFile variable to args[0] and run everything in the Open command starting from BufferedReader(FileReader(userFile));
I suggest you put all of that in a separate method which accepts a String argument, then use that method in both the method handling File > Open and the main method.
if you don't understand what I'm saying, let me know I'll draw up an illustration.
Ok, currently, is this roughly how your File > Open handling method works? When the user clicks File > Open, this method handles the event:

        {
            Display the "Open File" dialog to the user.
            Get the string 'userFile' from the dialog.
            BufferedReader(FileReader(userFile));
            while
            {
                ((line=b.readLine())!=null)
                doc.insertString(doc.getLength(), "ignore", style);
            }
        }
sorry the whole fixed font thing is screwing up
alright, here's how it should be split up: (hold on let me write it out)
When the user clicks File > Open, this method handles the event:
{
    Display the "Open File" dialog to the user.
    Get the string 'userFile' from the dialog.
    myMethod(userFile);
}

Write another method "myMethod (String userFile)":
{
    BufferedReader(FileReader(userFile));
    while
    {
        ((line=b.readLine())!=null)
        doc.insertString(doc.getLength(), "ignore", style);
    }
}
Finally, what you have to do in main method is this:
(Btw it actually doesn't matter where the [] are in String args[])
public static void main (String args[])
{
    set up your GUI and everything here first
    myMethod(args[0]); //this will open the incoming file and display its contents
}
BTW all my pseudocode above is under the assumption that inputs are always valid. In your actual code, you have to include various checks. In method handling File > Open, you'll have to check if user cancelled the Open dialog.
in myMethod you'll have to check whether a file by that name actually exists.
Hope this works now.
try the command line first after compiling mjar.jar
javaw.exe -jar "C:\...\mjar.jar" "C:\...\file.myext"
Off-topic: Eclipse seems to favor (String[] args) maybe that's why I'm used to it. Not sure which one Netbeans favors.
how about Testing argument: args[0]?
(I hope you're only putting ... in your paths to truncate them here in superuser.)
Oh, and please try File > Open even if the args[0] failed. You'll want to make sure myMethod works correctly.
is the GUI running?
Where did you place the Testing: args[0]?
it's not printing out in the command window?
show me the code line that should supposedly print it
hmm yes.
is it done before anything else?
well then it should get printed out, especially if rest of the main method executes.
Btw, does anything in your new myMethod depend on anything else? For example, does it have to wait for something to be setup, something that will surely be setup when user does File > Open, but may not be set up when the main method is executing on program start?
Actually I wanted you to split out the actual opening of file into myMethod so that you can re-use it in the main method.
public static void main (String args[])
{
    set up your GUI and everything here first
    myMethod(args[0]); //this will open the incoming file
}
see the myMethod(args[0]); there?
try again.
also tell me if Testing file args[0] prints out.
which line gives exception?
hey, will you stay online for another hour or two?
oh, i actually need to go now.
when will you be online next?
that's very strange, it shouldn't give an exception. even if there's no argument, the args[0] value would simply be a blank string.
what time and time zone+
?*
(or your location)
23 hours later you mean?
hmm ok
no problem.
i'll do some testing in the meanwhile, and post results up in this chat
See you.
 
2 hours later…
02:47
Here is the problem, the args array will have zero length if there are no arguments. You will need to have proper checks for the length of the array. Please try these in your main method (along with the necessary GUI stuff that would come before this code):
	public static void main (String[] args) {

		System.out.println ("args length = " + args.length);

		for (int i=0; i<args.length; i++) {
			System.out.println(args[i]);
		}

		if (args.length == 1) {
			myMethod(args[0]);
		}

	}
Sorry, please change if (args.length == 1) { to if (args.length >= 1) { so that it works even if more than one argument is supplied (the other arguments will be ignored).
I also found out that if you use javaw, the System.out.println does not print to the command window. You have to use the java command for that. It will probably not allow your GUI to run, but it can show you that the arguments are working correctly.
 
19 hours later…
22:23
Didn't catch you when you got online. So now your Java app works and can open file when the file is double-clicked?
23:17
@Mike Thanks for accepting :) So everything is working as intended right?

« first day (2 days earlier)      last day (15 days later) »