Package

Hi guys - kinda wierd issue i'm having.

I have a java source file called Start.java in a folder called program (just in windows)

Start.java has like 8 or 9 classes in it plus one class called Start.java with the main( ) method.

I want all these class files to be part of a package called utilstuff

At the "beggining" of Start.java source code file i type (on the first line)
package utilstuff;

Now I compile it. In my program folder I see the Start.java file, and a folder calld utilstuff, with all my class files in it - just fine.
So compiles fine.

When i go to run it - it gives me an error
Exception in thread "main" java.lang.NoSuchMethodError: main
Press any key to continue...

Without the package statement it compiles and runs just fine.

Thanks kindly
pauldhadiallaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
how do u run it? should be something like:

java utilstuff.Start
0
pauldhadiallaAuthor Commented:
objects - the class file which contains the main method is called Start.java - so I go javac Start.java to compile it and then java Start to run it
0
objectsCommented:
you need to specify the fully qualified classname to run class ie. you need to include the package name

java utilstuff.Start
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

vikraman_bCommented:
also when u want to compile java from different packages like
com.test1
under which some 10 classes
com.test2...etc
under which some classes..
At that time if u want to compile
use
javac -d . *.java
 thats means -d for package options and . for put the classes in the current directory or u can specify the path u want to put.

so if u runnig this commond in the currrent directory say c:/temp

under c:/temp u can see a new folder created com/test1/*.class and com/test2/*.class files

so if u want to run..
what objects said the same ..run the class which has main method
java com.test1 xxx
or java com.test2 YYY
0
vikraman_bCommented:
java com.test1.xxx
or java com.test2.YYY
0
vikraman_bCommented:
Better download IDE it will do for u...
u can go  for
http://www.eclipse.org/downloads/index.php
its free only
0
pauldhadiallaAuthor Commented:
Hi guys. Still getting the same issue. hmmm

I have my main Start.java sitting in a folder called  'program' (doesn't really matter what its called, its just on windows in this folder - nothing else in there)

At the top of the package it says:
package utilstuff;

I compile it - it compiles - creates a folder called utilstuff inside the program folder.

Now i go into the dos prompt and from the program folder run utilstuff.Start  AND also tried going into utilstuff folder and running Start from there.

Still something fishy.

I wonder if i have something with 'access' modifiers messed up - should all the classes have public methods only - and what about variables

Thanks kindly
0
objectsCommented:
u better post your code
0
vikraman_bCommented:
download eclipse it will automatically configure ..
just create a new class and press the run button..it will compile and run for u..
try this
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.