aspose file tools*
The moose likes Linux / UNIX and the fly likes Ubuntu Server CLASSPATH not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Ubuntu Server CLASSPATH not working" Watch "Ubuntu Server CLASSPATH not working" New topic
Author

Ubuntu Server CLASSPATH not working

Ampage Grietu
Greenhorn

Joined: Feb 23, 2014
Posts: 2

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?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14272
    
  21

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Ampage Grietu
Greenhorn

Joined: Feb 23, 2014
Posts: 2

If I echo the CLASSPATH it indeed shows the correct path.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14272
    
  21

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).
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

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


Customer surveys are for companies who didn't pay proper attention to begin with.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5837
    
    7

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)

JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ubuntu Server CLASSPATH not working