Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can Somebody guide me how to set classpath in Ubuntu  RSS feed

 
yashprit singh
Greenhorn
Posts: 5
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
Janeice DelVecchio
Bartender
Posts: 1812
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a SCJP question.... moving to beginner....
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • 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
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

/media/ENG_SONG/Learning_Assignment/JAVA/src$ java -cp ../classes Life
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!