Solved

java compile(class path)

Posted on 2001-06-29
11
647 Views
Last Modified: 2013-11-23
i've compiled the file e.java successfully
but when i try to run it using Java.exe like

C:\jdk1.3.0_02\bin>java -classpath <c:\classes12.zip> e.class
classpath requires class path specification-


i got the message u c above ,
i want to run it from the dos prompt and i don't want to use any IDE
Thank you
0
Comment
Question by:emadomar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 6237267
Hi,

   Open AUTOEXEC.BAT file and add the following

 path= c:\jdk1.2\bin;
 set classpath=c:\jdk1.2\lib;.;

   Save the file and restart the machine.

   It solves ur problem

bye
0
 

Expert Comment

by:Richard_Yu
ID: 6237300
Maybe you not include all classpath for necessary libarys. BTW, when you run a java program you sould not include the .class suffix. For example, you may try:

C\jdk1.3.0_02\bin>java -classpath <c:\classes12.zip;c:\jdk1.3.0_02\lib\tools.
jar;c:\jdk1.3.0_02\lib\jvm.lib> e

0
 
LVL 2

Expert Comment

by:jorj
ID: 6237345
maybe you should try to change '<' and '>' with " in classpath arguments
0
Independent Software Vendors: 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!

 

Expert Comment

by:rameshnut
ID: 6237446
Hi emadomar

Let me answer this type of question again!
I will suggest you a few steps, follow them and you will be successful in the execution of your program.

I observe that you are trying to run the class file from the bin directory.This is ok.but why dont you create your own directory say c:\emadomor.
Edit,save,compile and run your java programs from this folder.
(this is just a bit of advice!!)

secondly you 'should not' include the '.class' extension to run a java program.This results in an error.

next, CORE JAVA CLASSES do not require CLASSPATH TO BE SET.
java.exe is INTELLIGENT enough to locate the required class files (from jar/zip) and RUN them!

next, dont use the angled brackets to include the classpath.
Angled brackets are only a NOTATION used to help the developer how to use a particular program. (you might see this when you just type JAVA at the command prompt)

finally the error that your compiler throws is probably due to the fact that you included the angled brackets and the compiler is not able to recongize them.

to run your program successfully type the following sentence a the command prompt.
Assume the following,

* your class file name is e.class
* your working directory is c:\emadomar
* you have the path set to execute the java,javac files
* you have some classfile named some.class which is    
  residing in c:\emadomar\classes

type the following command now

java -classpath .;c:\emadmor\classes\some.class e

0
 
LVL 2

Expert Comment

by:jorj
ID: 6237476
What's this ????:
java -classpath .;c:\emadmor\classes\some.class e

So you said java to use some.class as classpath ??? Hehe. Publish that !
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6237506
all you have to do is to modify your command line from :
C:\jdk1.3.0_02\bin>java -classpath <c:\classes12.zip> e.class

to :
C:\jdk1.3.0_02\bin>java -classpath <c:\classes12.zip> e

For running a class file you must not specify the extension of that file (e.g. 'java Hello' instead of 'java Hello.class').

Cheers , nice answear you have there :).
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6237518
to : C:\jdk1.3.0_02\bin>java -classpath c:\classes12.zip e

0
 

Expert Comment

by:rameshnut
ID: 6237724
Hi all


as jori pointed out, i made a mistake.what i really meant was that instead of the class file you use a JAR file.
i mean if there was 'some.jar' then include THAT JAR FILE IN THE CLASSPATH (AND JUST NOT THE DIRECTORY IN WHICH THE JAR FILE IS PRESENT)
something like this

java -classpath .;c:\emadmor\classes\some.jar e

(correct me jori if i am wrong)

it was a mistake.

rameshnut
0
 
LVL 2

Expert Comment

by:jorj
ID: 6237742
You are forgiven. :) Hope you weren't angry with me; it was a joke.
0
 

Expert Comment

by:rameshnut
ID: 6240270
Hi all

if authors of java books were like 'ovi' no body would have ever learnt the language :-))
You seem to know things but you dont seem to be able to COMMUNICATE it to others!!.thats a pity!

i would have given answer exactly HALF THE SIZE OF YOURS he he .BUT...alas! emadomar would not have understood it(i assume that this person is a novice).

rameshnut
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8289498
All,
I am unlocking this question in preparation for cleanup.  I will return in 7 days to finalize this question.  Please leave any recommendations for the final state of this question, I will take all recommendations into consideration.  Failing any feedback, I may decide in 7 days to delete or PAQ this question with no refund.  Thanks.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

730 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