SIMPLE: help executing basic java command

I have been using IDEs for way too long... i can't execute a class

I am in mydir

in mydir is build

in build is


in myproduct is myclass with a main method

whne I'm in mydir, i am running

java -cp build org.demo.myproduct.myclass

but getting a no class def error, what am i doing wrong?
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.

Go into build and run

java -cp . org/demo/myproduct/myclass

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
Your command is correct for what information you've given
Are you trying to do this from the command line?

In the command line, navigate to mydir. Then you can either navigate to the folder with the files, or just type:

java build/org/demo/myproduct/myclass

It might be easier to navigate to the actual folder though. From mydir:

cd build
cd org
cd demo
cd myproduct
java myclass
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

jjacksnAuthor Commented:
jf - that doesn't not work, does it need to be qualified?  

ok, if I go into build, this works

java -cp . org/demo/myproduct/myclass

however, i'm executing in ANT, and my basedir is in the parent directory of build.  so how do I set my class path?
jjacksnAuthor Commented:
yeah, I don't know what was happening before, that does work from the command line.

however, in ANT i have:

<target name="create-keys">
      <java classname = "org.sharedrecords.demo.KeyStoreGenerator">
            <arg value = "build/org/sharedrecords/demo/utils"/>
            <classpath path="build"/>

and it doesn't work.
Mick BarryJava DeveloperCommented:

<target name="create-keys">
     <java classname = "org.sharedrecords.demo.KeyStoreGenerator">
          <arg value = "build/org/sharedrecords/demo/utils"/>
             <pathelement location="build"/>
jjacksnAuthor Commented:
still no luck.  Is there someway i can turn verbose mode on while running from eclipse?
jjacksnAuthor Commented:
i ran it from the command line... didn't see anything useful.  just "could not find org.sharedrecords.demo.KeyStoreGenerator"
Mick BarryJava DeveloperCommented:
> and my basedir is in the parent directory of build.

are you sure thats the case?  try settting the dir attribute for the java task
jjacksnAuthor Commented:
i used dir = "${basedire}"

a got this message      [java] Working directory ignored when same JVM is used.
Mick BarryJava DeveloperCommented:
run ant with -verbose and see what that tells you.
jjacksnAuthor Commented:
wow, so, as it turns out, suprisingly enough, KeySTOREGenerator != KeyPAIRGenerator.  that was fun.
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.