Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Path/Classpath Problem

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK... I *think* I understand the path and classpath variables. I'm not a beginning Java programmer, but this problem is pretty basic.

My home machine requires that any resources I use in my code be fully qualified. So I write code at work that loads a JAR just by using the name of the JAR and it works fine. At home, I have to modify the code so it loads it with 'c:/resources/some.jar', for example. I get the same problem with XML files, images, sounds, everything.

It's a winXP box, brand-new clean install with the latest SDK. What could possibly be causing this problem?
 
Ranch Hand
Posts: 249
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried an or an just to make sure you didn't do a typo when setting the variables on your machine?
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using the DOS command line or some GUI tool to compile your code?

If it's a GUI tool which one, and is it the same tool at home as at work?

Jeff
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William,

Do you have the current directory (.) in your classpath? Maybe at work you do but at home it is missing?

That probably would not account for all your problems, but it is worth checking.

PATH: used by the operating system to find executables (particularly javac.exe and java.exe, which are the java compiler and the java runtime, respecively)

CLASSPATH: used by the Java VM to find classes. Classes that are part of standard Java (such as java.lang.System and java.util.Vector) don't have to be added to the CLASSPATH, as Java VM inherently knows how to find them). But if you have code in a class that calls another class (creates an object, or calls a method) then you need to have that other class in your CLASSPATH.

One thing about classpath that seems to confuse some people is that while you can add directories to your classpath, you also can add jar files. Since a jar file is an archive of directories, it is considered a directory, so you must put the jar file in your classpath, not just the directory where the jar file is located.

That means if you have 10 jar files in the same directory you must add all ten of them to your classpath.

Tony
 
William A White
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I use NetBeans 3.6 both at home and work. I do have the current directory in my PATH here at home, though I think that is not necessary anyways.
 
Grow your own food... or this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic