Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do i set a/the classpath.

 
Jason Martin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just finished doing the Head First HTML, XHTML, and CSS book and i also got the Head First Java 2nd edition book. i didnt have any trouble with the xhtml book but im having problems getting this java one to work. I think i have narrowed it down to not have the classpath set to the right folder/s. I have Java and the JDk installed to C:\Java\bin and the folder with my .java and .class files in C:\Users\....\Desktop\JavaWork . now i managed to get it 1 of the .java files i made from reading the HF book into a .class file by moving the folder into the Java folder. but that shouldnt be right either from what i have read on here + on the Java Sun website. Also im on 64bit vista if that makes any difference. Thanks in advance for the help!
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason Martin wrote:I just finished doing the Head First HTML, XHTML, and CSS book and i also got the Head First Java 2nd edition book. i didnt have any trouble with the xhtml book but im having problems getting this java one to work. I think i have narrowed it down to not have the classpath set to the right folder/s. I have Java and the JDk installed to C:\Java\bin and the folder with my .java and .class files in C:\Users\....\Desktop\JavaWork . now i managed to get it 1 of the .java files i made from reading the HF book into a .class file by moving the folder into the Java folder. but that shouldnt be right either from what i have read on here + on the Java Sun website. Also im on 64bit vista if that makes any difference. Thanks in advance for the help!



first you don't have to set the classpath for your source files. in a dos window go to the directory which has your .java files run javac file.java I am guessing you don't have your files in a package?? next run your execute the class file accordingly java -cp . filename
 
Jason Martin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mk so i run CMD as an admin than set the directory to the javac file? and package such as inside a folder? and to run the .class file i have to type in java -cp(do i just type -cp in? or the C:\etc\etc than the actual file?) . HelloWorldApp ? first time trying to learn programing so sorry if i dont understand it all.
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can say java -cp . classname or you can put java -cp c:\whatever.classes classname the '.' refers to the current directory in which you are located so if you type cd .. at the dos prompt you will go up a directory if you type cd . then you stay in the same directory
 
Jason Martin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok get an error when trying to compile it: ' javac ' is not recognized as an internal or external command, operable program or batch file.
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to type set path=%PATH%;.;c:\java\bin 'enter'
 
Jason Martin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam LaFaye wrote:you have to type set path=%PATH%;.;c:\java\bin 'enter'

ah k that makes it work! /cheer 6 days of trying to fix this on my own and something as simple as that fixes it
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
recommend download eclipse ganymede and create java applications in it. then choose server runas applications it will do all the pathing for you
 
Jason Martin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam LaFaye wrote:you have to type set path=%PATH%;.;c:\java\bin 'enter'

ah k that makes it work! /cheer 6 days of trying to fix this on my own and something as simple as that fixes it
Hmm they should think about adding that to the Head First Java book or put it in a read me with the downloadable files for the book. Couldnt find it on Java's site either. they just say you need to change the path but dont tell you how to change it
 
Jason Martin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam LaFaye wrote:recommend download eclipse ganymede and create java applications in it. then choose server runas applications it will do all the pathing for you

:O where can i find it? also is it free? Iv got Adobe Creative Suite 4 btw if theres any programs in it that work with this.
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
free. just go to eclipse.org and download it. lots of tutorials available as well
 
Jason Martin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this one? Eclipse d/l
Edit: Prob a dif one since im on 64bit....
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that is what you want. I am using that version on Vista as well.
 
Jason Martin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kk. just wanted to make sure since it says 32bit. + i dont see a 64bit version any where
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic