Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

classpath - differences between java command line argument and environment variable  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran into problems using jdbc against a SQL Server db and discovered I need to set the class path to the following:
"C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.0\enu\sqljdbc.jar"

When I create an environment variable CLASSPATH in Windows XP and set it to the path above the program works fine. But setting it via a command line argument to java does not seem to work. Below is the command I'm using.

c:\Projects\java\JDBCtest2>java JdbcTest -CLASSPATH ".;C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.0\enu\sqljdbc.jar"

Does the syntax differ when using the command line or am I doing something else wrong?

Thanks!
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Delbert,

Welcome to JavaRanch!

The -classpath (not -CLASSPATH) switch is an argument to java.exe, not to your program, so it appears on the command line before, not after, your program. Altogether:

java -classpath ".;C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.0\enu\sqljdbc.jar" JdbcTest
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I ran into problems using jdbc against a SQL Server db and discovered I need to set the class path to the following:
"C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.0\enu\sqljdbc.jar"

When I create an environment variable CLASSPATH in Windows XP and set it to the path above the program works fine. But setting it via a command line argument to java does not seem to work. Below is the command I'm using.

c:\Projects\java\JDBCtest2>java JdbcTest -CLASSPATH ".;C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.0\enu\sqljdbc.jar"

Does the syntax differ when using the command line or am I doing something else wrong?

Thanks!



Try this:

 
Delbert Bell
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, now that you point it out it seems painfully obvious. I was getting pretty frustrated. Thanks for the help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!