java code working only with default package


I have created a class in the package


The class is called Tableaucmdautomation

it works fine from eclipse but when I try to execute it from command line then I get main class not found error

I have tried all the options of giving explicit classpath in the command line etc

So I tried one more thing , create the file without a package and then it works fine in the folder I have class file

to follow the best practice I want to stick to packages but I need to make sure that I can execute it from command lines as well.

What am I doing wrong here ?

PS: when I remove it from the package and put it in the default package. Then it works fine
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Amitkumar PSr. ConsultantCommented:
I gone thru snap provided by you. Follow below steps..

1. Goto c:\eclipse\workspace\test\bin dir.
2. Then run java -cp .; com.anshu.biautomation.tabcmd.Tableaucmdautomation

Basically, when we need to run class residing in a packge, we will have to provide entire package structure. Give it a try as suggested above and share the result.
I would rename your class to something more appropriate. The current name is rubbish.
anshumaEngineeringAuthor Commented:
Hi amit,

Your help has resolved the issue


can you please give me an example of a more appropriate name
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

I would need to know more about the role of the class i.e. what does it do?

Also you need to learn about using camel case in class naming.
Amitkumar PSr. ConsultantCommented:
Agree with gurpsbassi about naming convention.

Assuming that Tableaucmdautomation is for simple class for Tableau (similar to HelloWorld) for automation. If so, I would use below for package and class.

Package : com.anshu.automation.command.
Class : TableauCommand

You need to name it as per the job the class does and that is why gurpsbassi asked for the responsibility of your class.

Refer below links for more on naming standards. (hope this is a valid to post on EE)

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
anshumaEngineeringAuthor Commented:
The logic for this is

com.anshu ( i will have the name of the company)

.biautomation (stands for business intelligence automation)

.tabcmd (stands for tableau command manager) similalrly we can have one for Microstrategy (mstrcmd)

.Tableaucmdautomation this shows that this is the actual class that does automation specifically for triggering reports , other classes can be created for doing other automation work on tableau (may be adding tableau to this name is redundant)
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

From novice to tech pro — start learning today.