Member Avatar

Ok, here's the situation.

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


In, I'm trying to call a method within, 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.

Recommended Answers

All 9 Replies

ehm ... I'm not going to click outside links to check for your code.
paste it here in code tags.

Member Avatar

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.

or he forgot a parameter ... lots of things it could be, but hard to find without additional information.


call a method within,

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

Member Avatar

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 to

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!

either that, or make the method static.

Member Avatar

That too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.