Ok, here's the situation.

I've got a package filled with 4 .java files.


In Main.java, I'm trying to call a method within AQAReadTextFile2013.java, which also happens to be called "AQAReadTextFile2013".

I've tried calling it using the line:
* AQAReadTextFile2013.AQAReadTextFile2013("filepatharguement")
* AQAReadTextFIle2013("filepatharguement")

Within 'main', but they both give a 'symbol not found' error.

Any idea how to call this correctly?

I think it's a fundamental syntax error that i'm having an issue with, but I can't seem to find any help with this, as this is quite specific.

Sorry if the answer is obvious, I'm transitioning from C# to java and things seem a bit different here.

Thanks, Alex.

Edited by humorousone: Code > Link.

3 Years
Discussion Span
Last Post by humorousone

It was just an image of the four .java files in the package.
I've edited the OP.


yes, but it still is pointless. how can we see where in main you go wrong, if we don't get to see the code in your main class, or the code you are (trying to) call?


my guess: he has 4 source files and expects that he can just call methods in those without compiling them.
Another guess: he has loose methods in those source files that are not inside any classes.



call a method within AQAReadTextFile2013.java,

sounds very suspicious, even more as he doesn't even list such a file among what he claims to have available.


sounds very suspicious, even more as he doesn't even list such a file among what he claims to have available.

I made a mistake in my first post, so i'll clarify.

I tried to simplify the names of my java files in the list for the sake of post length, then in my haste forgot to edit the rest of my post.
(e.g I changed AQAReadTextFile2013.java to ReadTextFile.java)

I've done a bit more more research on other sites, and found my answer:

In order to call a method from anotehr class, I need to create an instance of the class i'm trying to call, then use that instance to call a method and send parameters.

For example:

Instead of just calling:


I'd instead:

//create a new instance of the class
WriteTextFile Input = new WriteTextFile();

//then call the method I want using that instance.

//just to be clear, AQAReadTextFile2013 is the method within the "WriteTextFile" class.

Sorry about the confusion!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.