Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CLASSPATH help 1

Status
Not open for further replies.

darine

Programmer
Jun 23, 2000
28
US
Hi for all<br>I hope someone knows sites or a books to help me to know<br>about CLASSPATH and how to set to read java packages.<br>because i want to pass parameters fro Java to JavaScript and i need to set the CLASSPATH to get the JSObject class<br>in java40.jar in netscape package.<br>Thanks for your time.
 
what operating system are you using? In win98se you have to set the classpath in the autoexec.bat and reboot the machine. <p> fenris<br><a href=mailto:fenris@hotmail.com>fenris@hotmail.com</a><br><a href= > </a><br>
 
Thanks for your time.that helps alot.<br>please i''m looking for something to read about that and how to set it.<br>if you know where can i read about it(CLASSPATH) that will be great for me.<br>Thanks again.
 
You can try java.sun.com and search for classpath<br><br><br> <p> fenris<br><a href=mailto:fenris@hotmail.com>fenris@hotmail.com</a><br><a href= > </a><br>
 
Here's what I do- I create a batch script that will run my Java for me.<br><br>Here's how I do it:<br><br>1) I create a text file- let's say &quot;new.txt&quot;.<br>2) Now I have to rename it to &quot;new.bat&quot;.<br>3) Then I list the commands I'd throw at a command line.<br><br>@set CLASSPATH=&quot;..\..\..\class;..\..\..\src;..\..\..\lib\Stuff.jar;..\..\..\lib\Tools.jar;&quot;<br>@java -cp %CLASSPATH% MyJavaClass<br><br>4) Then I run the batch file.<br><br>I'll explain this process. First, if you edit the classpath in a batchfile, you don't need to reboot your machine and you don't have to worry about your classpath interfering with the permanent classpath already set in autoexec.bat.<br>Second, you don't have to type it all in every time if you put it in a batch file- just type it once and run it anytime (as opposed to writing it once and running it anywhere, uh huh).<br><br>Now I'll explain what exactly is in the batch file. First, the @ symbols. Those are there so the statements don't get echoed at the commandline- I don't want to actually see the statements, I just want them executed. Second, the &quot;set CLASSPATH=....&quot;. This is the relative path to all the classes that need to be included when I run my program. If you don't remember old DOS stuff, &quot;..\&quot; means the parent directory- so if my class files are under &quot;C:\class&quot; and my batch file is in &quot;C:\myjava\source\project1\&quot;, my classpath would have to include &quot;..\..\..\class&quot; (I think that's right). The .jar files are zipped up files that contain class files inside them. You may or may not have to worry about them, depending on whether or not you're working with .jar files.<br><br>Then, I have my java line. -cp is the classpath switch; %CLASSPATH% is the classpath we just specified (the % on both sides means it's a variable in the batch file that you have just set).<br><br>I hope that helps! :eek:) If you have any problems with this method, please let me know. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
Liam, excellant suggestion! I think that it should be made into a FAQ.<br><br>From the looks of it you are running win98? What you could do with this batch file is set it to run in your shortcut to the dos prompt. Simply put the location of your batch file into the batch file field (I am at an NT station right now so I can't confirm) and go from there. This is what I do to start up doskey whenever I enter the ms-dos prompt.<br><br> <p> fenris<br><a href=mailto:fenris@hotmail.com>fenris@hotmail.com</a><br><a href= > </a><br>
 
I'm running on NT too, although I run win98 at home (well, I did, before I fried my motherboard, as I think you saw in the PC Hardware forum- ouch).<br><br>As for doskey- that's something I have in autoexec.bat. <br><br>Since batch files run in DOS, why make a DOS shortcut for it? Just double-click the batch file, and it will load your classpath and run your java program (just make sure to include an '@pause' as the last line of your batch file if you need to view what the Java app prints to the screen). Unless I don't understand you correctly...<br><br>And thanks for the Tipmaster vote, I think I'll throw that in as a faq at your suggestion :eek:) <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
I guess your right Liam, I have two reasons that I use the command prompt, one is force of habit :) and the other is that I develop on linux as well and it doesn't have batch files (I know there are things like pearl scripts and such, but I haven't learned how to use these yet). I am definately going to use batch files more often.<br><br><br><br> <p> fenris<br><a href=mailto:fenris@hotmail.com>fenris@hotmail.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top