Link to home
Start Free TrialLog in
Avatar of jjacksn
jjacksn

asked on

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

org/demo/myproduct

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?
ASKER CERTIFIED SOLUTION
Avatar of SnO2d
SnO2d

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
SOLUTION
Avatar of CEHJ
CEHJ
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
Avatar of jfredrickson
jfredrickson

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
Avatar of jjacksn

ASKER

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?
Avatar of jjacksn

ASKER

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"/>
      </java>
</target>

and it doesn't work.
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 jjacksn

ASKER

still no luck.  Is there someway i can turn verbose mode on while running from eclipse?
Avatar of jjacksn

ASKER

i ran it from the command line... didn't see anything useful.  just "could not find org.sharedrecords.demo.KeyStoreGenerator"
> 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
Avatar of jjacksn

ASKER

i used dir = "${basedire}"

a got this message      [java] Working directory ignored when same JVM is used.
run ant with -verbose and see what that tells you.
Avatar of jjacksn

ASKER

wow, so, as it turns out, suprisingly enough, KeySTOREGenerator != KeyPAIRGenerator.  that was fun.
:-)