• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ubuntu Server CLASSPATH not working

 
Greenhorn
Posts: 2
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a program that I finished and compiled on one computer in our lab. It is saved under my username for Ubuntu Server. It imports a package that compiled fine on that computer, as well as most others. However, that lab is currently in use so I am in another one. I logged into my account and tried compiling the same program, and it is failing to import the package. I opened up the .bashrc file and lo, the CLASSPATH is still set and the packages have not moved. Is there an explanation as to why this is happening and how it could be fixed?
 
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
Welcome to the Ranch.

If you type:

echo $CLASSPATH

then what is printed; is it the correct classpath that you expected? If not, then the setting in .bashrc is not being used for some reason; you'd have to dig around a little in the system to find out why not.
 
Ampage Grietu
Greenhorn
Posts: 2
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I echo the CLASSPATH it indeed shows the correct path.
 
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
Ok, then you'll have to be a little more specific. What does the content of the CLASSPATH look like? Are there no typos, no spaces that should not be there, etc.? Note that on Ubuntu, directories and jar files in the CLASSPATH should be separated with colons ":" and not semi-colons ";" as on Windows. (If you use semi-colons, it will not work).
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, don't forget that the classpath entries refer to where the package roots are located.

If you specify "CLASSPATH=/var/lib/myapp/classes", then the actual location of the classfile for com.javaranch.testproject.Helpme MUST be /var/lib/myapp/classes/com/javaranch/testproject/Helpme.class
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I advise against setting CLASSPATH in .bashrc, doing so will almost guarantee that you will have some unwanted surprises. It is better to set it within a script taht passes the value as the -cp entry on the java command line itself. Also if you do that you can use ps to view the command line used to run the java executable to verify that you got it correct (which is handy if a script start the app)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic