• 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

How to include sub folders to classpath and Where to store the drivers?

 
Ranch Hand
Posts: 75
Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all. As shown in below diagram , my class files are in out folder and resource files are in res folder. Now in the classpath I have given two paths i.e(C:\Users\Iteam1\Desktop\Rajeev\firstproject\out and C:\Users\Iteam1\Desktop\Rajeev\firstproject\res) .Now it compiles and executes but If I give classpath upto(C:\Users\Iteam1\Desktop\Rajeev\firstproject\) it is not executing. So. where I'm going wrong i.e how to include sub folders also in a single line? My second question is which is the efficient place to keep the database driver. In my project I'm using postgres driver and I kept in ext folder (C:\Program Files\Java\jre1.8.0_73\lib\ext). So is that a correct way or should I keep one more folder named driver and put the driver there and after that keeping the driver path in classpath. ?
1.JPG
[Thumbnail for 1.JPG]
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't create new folders in the Program Files tree. You will have to put both folders in the CLASSPATH separately, I think.
 
Rajeev Srikhar
Ranch Hand
Posts: 75
Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't meant creating folder in program files but along side with the three sub folders(out,res,src).
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where are the postgres driver classes usually installed?
 
Rajeev Srikhar
Ranch Hand
Posts: 75
Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know that. What I know is If we want our java program to interact with postgres database we need drivers and those drivers should be in classpath. So I kept in ext folder.
 
Rajeev Srikhar
Ranch Hand
Posts: 75
Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right Mr. Campbell.. we have to put both directories separately.
 
Saloon Keeper
Posts: 15485
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you should take a look at Maven. Maven can handle multiple source paths, resource paths and dependencies for you.

You can set maven up so that it will build your application as a JAR, containing a main class and having all its runtime dependencies on the class path automatically. Building then becomes as easy as running the command "mvn package".

Maven's norm is to have all your sources in src/main/java/ and all your resources in src/main/resources/. Dependencies should almost never be in the extension folder of your runtime, but you don't have to worry about this as Maven handles it for you automatically.
 
Rajeev Srikhar
Ranch Hand
Posts: 75
Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's great information on Maven. But as of now I need to do my project using notepad and DOS commands only as my superior think I could learn basics. So, my question is which is ideal place for storing driver when we aren't working with IDE.
 
Stephan van Hulst
Saloon Keeper
Posts: 15485
363
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well in that case, I usually put my dependencies in a lib folder inside my project. The manifest file of the JAR should contain a class path entry that contains all the JARs within the lib folder. Here's an example of the manifest:
 
reply
    Bookmark Topic Watch Topic
  • New Topic