Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Multiple classes with main() in single package
Multiple classes with main() in single package [message #756553] Mon, 14 November 2011 09:52 Go to next message
Mario  is currently offline Mario Friend
Messages: 3
Registered: November 2011
Junior Member
Hi!

Can someone please explain to me how to create multiple classes (each with its own main method) under one package and one project?

I have a following structure:

lesson1 - program1, program2, program3 ...
lesson2 - program1, program2, program3 ...
...

Every program is independent and has its own main() method. But programs should belong to lesson package -> first 3 programs should belong to xxx.xxx.lesson_1, next 3 to xxx.xxx.lesson_2 etc.

So, one project -> multiple lessons each containing multiple classes and every class has its own main() method.
Re: Multiple classes with main() in single package [message #756558 is a reply to message #756553] Mon, 14 November 2011 10:12 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 14.11.2011 10:52, Mario wrote:
> Hi!
>
> Can someone please explain to me how to create multiple classes (each
> with its own main method) under one package and one project?
>
> I have a following structure:
>
> lesson1 - program1, program2, program3 ...
> lesson2 - program1, program2, program3 ...
> ..
>
> Every program is independent and has its own main() method. But
> programs should belong to lesson package -> first 3 programs should
> belong to xxx.xxx.lesson_1, next 3 to xxx.xxx.lesson_2 etc.
>
> So, one project -> multiple lessons each containing multiple classes
> and every class has its own main() method.
Just create a class for each program in the right package.

Dani
Re: Multiple classes with main() in single package [message #756563 is a reply to message #756558] Mon, 14 November 2011 10:50 Go to previous messageGo to next message
Mario  is currently offline Mario Friend
Messages: 3
Registered: November 2011
Junior Member
Dani Megert wrote on Mon, 14 November 2011 05:12

Just create a class for each program in the right package.

I've tried that, but Eclipse only runs first program. When I try to execute program 2 I get error "can't find main()" or something like that.
Re: Multiple classes with main() in single package [message #756572 is a reply to message #756563] Mon, 14 November 2011 11:44 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 14.11.2011 11:50, Mario wrote:
> Dani Megert wrote on Mon, 14 November 2011 05:12
>> Just create a class for each program in the right package.
>
> I've tried that, but Eclipse only runs first program. When I try to
> execute program 2 I get error "can't find main()" or something like that.
Just select the class and then run it.

Dani
Re: Multiple classes with main() in single package [message #756583 is a reply to message #756572] Mon, 14 November 2011 12:13 Go to previous message
Mario  is currently offline Mario Friend
Messages: 3
Registered: November 2011
Junior Member
Dani Megert wrote on Mon, 14 November 2011 06:44

Just select the class and then run it.

I was doing that and it didn't work.

Now it works. The problem was in main() method parameters - I've omitted "String[] args" so main method couldn't be found. Stupid me, didn't see it.

Thanks!
Previous Topic:Open a java-source file from a plugin?
Next Topic:Installing m2e and wtp on eclipse helios 3.6
Goto Forum:
  


Current Time: Thu Apr 25 10:21:18 GMT 2024

Powered by FUDForum. Page generated in 0.08658 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top