File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classpath - differences between java command line argument and environment variable

 
Delbert Bell
Greenhorn
Posts: 6
  • 0
  • 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!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • 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
 
Richard Anderson
Ranch Hand
Posts: 61
  • 0
  • 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
  • 0
  • 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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic