[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SIMPLE: help executing basic java command

Posted on 2006-04-26
13
Medium Priority
?
256 Views
Last Modified: 2010-03-31
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?
0
Comment
Question by:jjacksn
  • 6
  • 3
  • 2
  • +2
13 Comments
 

Accepted Solution

by:
SnO2d earned 1200 total points
ID: 16548198
Go into build and run

java -cp . org/demo/myproduct/myclass
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 400 total points
ID: 16548506
Your command is correct for what information you've given
0
 
LVL 4

Expert Comment

by:jfredrickson
ID: 16548572
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:jjacksn
ID: 16549490
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
 
LVL 5

Author Comment

by:jjacksn
ID: 16549514
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
 
LVL 92

Assisted Solution

by:objects
objects earned 400 total points
ID: 16549894
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
 
LVL 5

Author Comment

by:jjacksn
ID: 16549928
still no luck.  Is there someway i can turn verbose mode on while running from eclipse?
0
 
LVL 5

Author Comment

by:jjacksn
ID: 16549944
i ran it from the command line... didn't see anything useful.  just "could not find org.sharedrecords.demo.KeyStoreGenerator"
0
 
LVL 92

Expert Comment

by:objects
ID: 16549946
> 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
 
LVL 5

Author Comment

by:jjacksn
ID: 16550163
i used dir = "${basedire}"

a got this message      [java] Working directory ignored when same JVM is used.
0
 
LVL 92

Expert Comment

by:objects
ID: 16550165
run ant with -verbose and see what that tells you.
0
 
LVL 5

Author Comment

by:jjacksn
ID: 16550170
wow, so, as it turns out, suprisingly enough, KeySTOREGenerator != KeyPAIRGenerator.  that was fun.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16550744
:-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month17 days, 22 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question