• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Environment Variable problem...

 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have a major problem.... I can't setup my environment variable (in System properties-Environment Variables) for some struts libraries, neither for JDBC/Connector (and now I try with Hibernate....Nothing again). Whet set them into PATH variable (or CLASSPATH) there is no efect. Compiler just do not read them.The only way to compile my code is to put libraries into jre/lib/ext (but in Struts I must delete them from there or server wouldn't start, and for Hibernate I can't also to hold there libraries). So what is the problem? I mean, I'm completely confused about situation, and stucked-up.... What is the problem and what should I do?
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Slobodan,

Please explain about your environment and how do you try to set CLASSPATH and PATH varaiable. Otherwise we would be only guessing whats wrong.

OK the first guess is the CLASSPATH set properly set with delimiter ( ; in WINDOWS and : in case of UNIX)
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right click at my computer-> properities->Advance tab-> Environment Variables. Select CLASSPATH, enter location of files need during compilation, and confirms. I mean, I have set these variables for Java, Tomcat itd. But I cant't set it up for Struts. It's mean I cannot "pull" classes I need to compile some .java file inside what I've import some classes. If I set the env. var. like I descibe, nothing happens. If I put the libraries into jre\lib\ext folder, the compilation is success. But I cannot start the server until I erase them from there (and it's quite severe to perform that each time). That is the problem..
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But I cant't set it up for Struts. It's mean I cannot "pull" classes I need to compile some .java file inside what I've import some classes.



If i understood correctly you need to struts jar in classpath and why dont you copy struts libraries in a separate folder ( C:\JARS) and include it in CLASSPATH like

C:\JARS\struts.jar; at the beginning of the CLASSPATH ( before other env paths )
and restart the server.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a rigth. Thanks!
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just one more thing. I've previously try to add whole folder into class path, and it didn't work. Why is that, why should I need to add path with name of jar file, when I didn't do that when I was setting libraries for server, for java.... In the both case I have add the path of folder contain libraries within. Can you explain me that? Thanks, one more...
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

when I didn't do that when I was setting libraries for server, for java.... In the both case I have add the path of folder contain libraries within



I guess thats because that you have * wildcard character after directory structure /* which implies - include all jar files inside the directory.

Usually Classpath is where teh JVM finds for classes and resources like properties files. So to indicate that class files (inside jar) its needed to specify jar name otherwise if you have .class file ,then specifying the directory alone would suffice. HTH.
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I have no wild card, really. Just a path of folders inside what is the libraries, that's all...
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

well again, did you setup thru any IDE ? that would take care of including *. If not , then show me the Classpath value
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Folks,

The CLASSPATH environment variable is an ugly hack. It can be convenient to get beginners going, but by the time you're posting in this Intermediate forum, you shouldn't be using anyway. Furthermore, Struts implies a Servlet container, which will not use CLASSPATH to find libraries anyway!

Both "java" and "javac" accept a "-cp" command line argument; you use it like

javac -cp c:\struts\struts.jar;c:\servlets\servlet-api.jar;c:\otherstuff;. MyClass.java

If that's too much typing -- and of course it is -- then you need to learn about Apache Ant for managing your build process, which will "type" all of this for you.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agreed EFH. Though intermediate forum is inappropriate for this discussion , certainly we need to be clear in basics when it matters.
reply
    Bookmark Topic Watch Topic
  • New Topic