• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Can Somebody guide me how to set classpath in Ubuntu

 
Greenhorn
Posts: 5
MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am totally new to Ubuntu as i have done with everything except setting CLASSPATH and PATH for java 6.
i googled this question but didn't get my work done. i don't want to do spam by asking repeating question i am really facing problem that's why i am asking this question
can somebody tell me how to do this but in simple way as i even don't know which type of shell i am using

when i type

i got


what i want is that setting class path for my class which is in another drive not on where ubuntu is installed drive was created by windows and have formate NTFS
total path to my folder where my source file are stored is
/media/ENG_SONG/Learning_Assignment/JAVA/src$
and my class file are stored in
/media/ENG_SONG/Learning_Assignment/JAVA/class$
.java file can be complied and stored in class folder in windows by doing



now how to attain this in Ubuntu
so totally i am having these question can somebody explain me this and tell me how to do these thing
PS i don want to use netbeans and eclipse or any IDE
P.S. Sorry for bad English
 
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a SCJP question.... moving to beginner....
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Ubuntu, like all Unix-like operating systems, you must use / (forward slash) instead of \ (backslash) to separate names on a path. Also, to separate entries, you use : (colon) on Ubuntu instead of ; (semi-colon).

If the class files that you want to put on the CLASSPATH are in /media/ENG_SONG/Learning_Assignment/JAVA/class, then just put that directory on the classpath with the -cp switch:

javac -cp /media/ENG_SONG/Learning_Assignment/JAVA/class -d ../class MyProgram.java

Run it with (assuming your src directory is still the current directory):

java -cp /media/ENG_SONG/Learning_Assignment/JAVA/class:../class MyProgram
 
yashprit singh
Greenhorn
Posts: 5
MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got my path variable ready now i am only facing problem ib classpath

my current working directory is:


now i complied java program by this:

till now every thing works fine but as soon as i run my program from this directory

i am getting NoClassDefFoundError
i have also tried to chnage my working directory then checked weather it working or not


whereas codechef is package name defined in java file its creating package but not running my program
i know this is related to CLASSPATH
can anybody tell me how to do this in exact way
please guys help me out as i am running out of time
 
Marshal
Posts: 76822
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you set your PATH? Did you edit .bashrc or another file? Have you set a CLASSPATH in that file? It is usually a bad idea to set a system CLASSPATH; it may be better to delete it and start from scratch.
 
yashprit singh
Greenhorn
Posts: 5
MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you guys for your help
i am done
i have just add classpath and path variable in /etc/environment

thank you Jesper de Jong and Campbell Ritchie
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this:

/media/ENG_SONG/Learning_Assignment/JAVA/src$ java -cp ../classes Life
 
reply
    Bookmark Topic Watch Topic
  • New Topic