Solved

java compile(class path)

Posted on 2001-06-29
11
636 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
  • 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
varialbe initialization 11 37
servlet filter example 37 72
Error in @AspectJ Based AOP with Spring 2 18
Glassfish admin console not working 1 34
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

831 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