set classpath for jar file

H

HS1

Hello

I have an application that uses some jar files in different folders. For
example, it needs

c:\folder1\file1.jar
c:\folder1\file2.jar
c:\folder2\file1.jar

I want to create classpath for those files. Do I have point out the exact
jar files as above in classpath or I can create by doing something like:

c:\folder1
c:\folder2

Thank you
SH1
 
H

hilz

HS1 said:
Hello

I have an application that uses some jar files in different folders. For
example, it needs

c:\folder1\file1.jar
c:\folder1\file2.jar
c:\folder2\file1.jar

I want to create classpath for those files. Do I have point out the exact
jar files as above in classpath or I can create by doing something like:

c:\folder1
c:\folder2

Thank you
SH1

You have to explicitly add every jar file to the class path. if you add the
directory to the classpath, it will add any classes inside it but not jar
files.
HTH
hilz
 
R

Rizwan

My question is about the classes which you mention will be included if we
add directory to the classpath.
what if the directory has a sub directory which also have classes? Will they
be included too automatically? If not then is there a setting option
available to do that? its lot of work to include each sub directory.
TIA
 
M

Michael Borgwardt

Rizwan said:
My question is about the classes which you mention will be included if we
add directory to the classpath.
what if the directory has a sub directory which also have classes? Will they
be included too automatically? If not then is there a setting option
available to do that? its lot of work to include each sub directory.

If the subdirectories reflect a package structure, only to root of that
structure needs to be added to the classpath.
 
O

Oscar kind

HS1 said:
Hello

I have an application that uses some jar files in different folders. For
example, it needs

c:\folder1\file1.jar
c:\folder1\file2.jar
c:\folder2\file1.jar

I want to create classpath for those files. Do I have point out the exact
jar files as above in classpath or I can create by doing something like:

c:\folder1
c:\folder2

Neither: the references in the Class-Path: header work the same as the
classpath to javac and java, but they only allow relative paths, and the
directory separator is '/'.

See the JAR File Specification, under section "Main Attributes":
http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html

PS: The directory separator doesn't seem to be mentioned, but I prefer '/'
because '\' also denotes special characters (tab, newline, unicode, ...).
 
Joined
Sep 6, 2009
Messages
5
Reaction score
0
i have error :classnotfoundeception :com.mysql.jdbc.driver..when i wann run this program......................
......................
mport java.sql.*;

class CreateTable
{
public static void main(String args[])
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
"jdbc:mysql:192.168.1.4:3306/test","root","212077"//192.168.1.102:3306/test",
//"root", "mysql");
Statement stmt=con.createStatement();
String sql="Create Table item_mast " +
"(item_code Numeric(4) Primary Key," +
" name Varchar(30)," +
" qty Numeric(4)," +
" rate Numeric(8,2))";
stmt.executeUpdate(sql);
System.out.println("The table \"item_mast\" successfully created.");
stmt.close();
con.close();
}
catch(Exception e)
{
System.out.println("Error: " + e);
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top