Link to home
Start Free TrialLog in
Avatar of Amit
AmitFlag for United States of America

asked on

java code working only with default package

Hi,

I have created a class in the package

User generated imagecom.anshu.biautomation.tabcmd

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
Avatar of Am P
Am P
Flag of India image

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.
Avatar of Amit

ASKER

Hi amit,

Your help has resolved the issue

@gurpsbassi

can you please give me an example of a more appropriate name
SOLUTION
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Amit

ASKER

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)