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?
LVL 5
jjacksnAsked:
Who is Participating?
 
SnO2dCommented:
Go into build and run

java -cp . org/demo/myproduct/myclass
0
 
CEHJCommented:
Your command is correct for what information you've given
0
 
jfredricksonCommented:
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
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.

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

and it doesn't work.
0
 
objectsCommented:
try:

<target name="create-keys">
     <java classname = "org.sharedrecords.demo.KeyStoreGenerator">
          <arg value = "build/org/sharedrecords/demo/utils"/>
          <classpath>
             <pathelement location="build"/>
          </classpath>
     </java>
</target>
0
 
jjacksnAuthor Commented:
still no luck.  Is there someway i can turn verbose mode on while running from eclipse?
0
 
jjacksnAuthor Commented:
i ran it from the command line... didn't see anything useful.  just "could not find org.sharedrecords.demo.KeyStoreGenerator"
0
 
objectsCommented:
> 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
0
 
jjacksnAuthor Commented:
i used dir = "${basedire}"

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

All Courses

From novice to tech pro — start learning today.