Problem in classpath

I am having a few problems with my Java program. My program Document1.java, requires the file PositionLayout.java to work. I use the compile line 'javac -classpath . Document1.java' to make it compile without errors (as PositionLayout.java is in the same directory). However I then need to use 'java -classpath . Document1' to run the program, otherwise I get a NoClassDefFoundError if I use 'java Document1'. The problem now is that Document1.java queries a database, and when I click a button on the program to query the database I get a error when running: -
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
catch (ClassNotFoundException ce) {
System.out.println("Unable to Load Driver Class "); }
I get an error saying 'No suitable driver'. I have a feeling it is because I am telling the classpath to look in the current directory for the PositionLayout.java file and so the Document1.java can not find the jdbc class it needs.
How can I correct this?

OK i made a jar file of the Position class files and put them in that directory. The Document1.java now compiles without me having to specify the classpath but when i try to run it using 'java Document1' it comes up with the NoClassDefFoundError in main. When I try specifying the classpath again it comes up with the same error as before.
I have included the files I am using here if anyone wants to try this themselves.
LayoutManager3.java
// A simple alternative to LayoutManager2 that provides for a
// consistent way of getting and setting constraints for the
// components in a container.
import java.awt.*;
import java.io.*;
public interface LayoutManager3 extends LayoutManager, Cloneable
public abstract Object getConstraints(Component comp);
public abstract void setConstraints(Component comp, Object cons);
public abstract Object clone();
PositionConstraints.java
// The constraints for each component in a position layout manager.
// If the width or height is set to -1 (the default), then the
// component will automatically size to its preferred size in that
// dimension.
import java.awt.*;
public class PositionConstraints implements Cloneable
public static final int NONE = 0;
public static final int BOTH = 1;
public static final int HORIZONTAL = 2;
public static final int VERTICAL = 3;
public static final int NORTH = 1;
public static final int NORTHEAST = 2;
public static final int EAST = 3;
public static final int SOUTHEAST = 4;
public static final int SOUTH = 5;
public static final int SOUTHWEST = 6;
public static final int WEST = 7;
public static final int NORTHWEST = 8;
public int x;
public int y;
public int width;
public int height;
public int anchor;
public int fill;
public Insets insets;
//-1 for width or height means use the preferred size
public PositionConstraints()
x = 0;
y = 0;
width = -1;
height = -1;
anchor = NONE;
fill = NONE;
insets = new Insets(0, 0, 0, 0);
public Object clone()
PositionConstraints p = new PositionConstraints();
p.x = x;
p.y = y;
p.width = width;
p.height = height;
p.anchor = anchor;
p.fill = fill;
p.insets = (Insets)insets.clone();
return p;
PositionLayout.java
// A custom constraint-based layout manager for laying out components
// in the traditional positional way (a component at any X and Y
// coordinate with any width and height).
import java.awt.*;
import java.beans.*;
import java.util.*;
public class PositionLayout implements LayoutManager3
private static final int PREFERRED = 0;
private static final int MINIMUM = 1;
private Hashtable consTable = new Hashtable();
private PositionConstraints
defaultConstraints = new PositionConstraints();
public int width;
public int height;
//-1 for width or height means use the preferred size
public PositionLayout()
width = -1;
height = -1;
public PositionLayout(int w, int h)
width = w;
height = h;
public void addLayoutComponent(String name, Component comp)
//Not used. The user should call setConstraints, and then just
//use the generic add(comp) method, like with GridBagLayout.
public Object getConstraints(Component comp)
return lookupConstraints(comp).clone();
public void layoutContainer(Container parent)
Component comp;
Component[] comps;
PositionConstraints cons;
Dimension d;
Dimension pD;
int x;
int y;
comps = parent.getComponents();
Insets insets = parent.getInsets();
pD = parent.getSize();
for (int i = 0; i < comps.length; i++)
comp = comps;
cons = lookupConstraints(comp);
x = cons.x + cons.insets.left + insets.left;
y = cons.y + cons.insets.top + insets.top;
d = comp.getPreferredSize();
if (cons.width != -1)
d.width = cons.width;
if (cons.height != -1)
d.height = cons.height;
if ((cons.fill == PositionConstraints.BOTH) ||
(cons.fill == PositionConstraints.HORIZONTAL))
x = insets.left + cons.insets.left;
d.width = pD.width - cons.insets.left - cons.insets.right -
insets.left - insets.right;
if ((cons.fill == PositionConstraints.BOTH) ||
(cons.fill == PositionConstraints.VERTICAL))
y = insets.top + cons.insets.top;
d.height = pD.height - cons.insets.top - cons.insets.bottom -
insets.top - insets.bottom;
switch (cons.anchor)
case PositionConstraints.NORTH:
x = (pD.width - d.width) / 2;
y = cons.insets.top + insets.top;
break;
case PositionConstraints.NORTHEAST:
x = pD.width - d.width - cons.insets.right - insets.right;
y = cons.insets.top + insets.top;
break;
case PositionConstraints.EAST:
x = pD.width - d.width - cons.insets.right - insets.right;
y = (pD.height - d.height) / 2;
break;
case PositionConstraints.SOUTHEAST:
x = pD.width - d.width - cons.insets.right - insets.right;
y = pD.height - d.height - cons.insets.bottom -
insets.bottom;
break;
case PositionConstraints.SOUTH:
x = (pD.width - d.width) / 2;
y = pD.height - d.height - cons.insets.bottom -
insets.bottom;
break;
case PositionConstraints.SOUTHWEST:
x = cons.insets.left + insets.left;
y = pD.height - d.height - cons.insets.bottom -
insets.bottom;
break;
case PositionConstraints.WEST:
x = cons.insets.left + insets.left;
y = (pD.height - d.height) / 2;
break;
case PositionConstraints.NORTHWEST:
x = cons.insets.left + insets.left;
y = cons.insets.top + insets.top;
break;
default:
break;
comp.setBounds(x, y, d.width, d.height);
private Dimension layoutSize(Container parent, int type)
int newWidth;
int newHeight;
if ((width == -1) || (height == -1))
Component comp;
Component[] comps;
PositionConstraints cons;
Dimension d;
int x;
int y;
newWidth = newHeight = 0;
comps = parent.getComponents();
for (int i = 0; i < comps.length; i++)
comp = comps[i];
cons = lookupConstraints(comp);
if (type == PREFERRED)
d = comp.getPreferredSize();
else
d = comp.getMinimumSize();
if (cons.width != -1)
d.width = cons.width;
if (cons.height != -1)
d.height = cons.height;
if (cons.anchor == PositionConstraints.NONE)
x = cons.x;
y = cons.y;
else
x = cons.insets.left;
y = cons.insets.top;
if ((cons.fill != PositionConstraints.BOTH) &&
(cons.fill != PositionConstraints.HORIZONTAL))
newWidth = Math.max(newWidth, x + d.width);
else
newWidth = Math.max(newWidth, d.width + cons.insets.left +
cons.insets.right);
if ((cons.fill != PositionConstraints.BOTH) &&
(cons.fill != PositionConstraints.VERTICAL))
newHeight = Math.max(newHeight, y + d.height);
else
newHeight = Math.max(newHeight, d.height + cons.insets.top +
cons.insets.bottom);
if (width != -1)
newWidth = width;
if (height != -1)
newHeight = height;
else
newWidth = width;
newHeight = height;
Insets insets = parent.getInsets();
return (new Dimension(newWidth + insets.left + insets.right,
newHeight + insets.top + insets.bottom));
private PositionConstraints lookupConstraints(Component comp)
PositionConstraints p = (PositionConstraints)consTable.get(comp);
if (p == null)
setConstraints(comp, defaultConstraints);
p = defaultConstraints;
return p;
public Dimension minimumLayoutSize(Container parent)
return layoutSize(parent, MINIMUM);
public Dimension preferredLayoutSize(Container parent)
return layoutSize(parent, PREFERRED);
public void removeLayoutComponent(Component comp)
consTable.remove(comp);
public void setConstraints(Component comp, Object cons)
if ((cons == null) || (cons instanceof PositionConstraints))
PositionConstraints pCons;
if (cons == null)
pCons = (PositionConstraints)defaultConstraints.clone();
else
pCons = (PositionConstraints)
((PositionConstraints)cons).clone();
consTable.put(comp, pCons);
//The following is necessary for nested position layout
//managers. When the constraints of the component are set
//to be elastic or non-elastic, then check to see if the
//component itself is a container with a position layout
//manager and, if so, set the layout manager itself to be
//elastic or non-elastic as necessary.
if (Beans.isInstanceOf(comp, Container.class))
if (((Container)Beans.getInstanceOf(comp,
Container.class)).getLayout()
instanceof PositionLayout)
PositionLayout layout;
layout = (PositionLayout)
((Container)Beans.getInstanceOf(comp,
Container.class)).getLayout();
layout.width = pCons.width;
layout.height = pCons.height;
public Object clone()
PositionLayout p = new PositionLayout(width, height);
return p;
Document1.java
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.Properties;
import java.io.*;
public class Document1 extends Frame implements ActionListener {
private Button Command1;
private TextField TextBox1;
public Document1() {
PositionLayout posLayout = new PositionLayout();
setLayout(posLayout);
PositionConstraints pCons;
pCons = new PositionConstraints();
pCons.x = 0;
pCons.y = 0;
Command1 = new Button("Command1");
Command1.addActionListener(this);
posLayout.setConstraints(Command1, pCons);
add(Command1);
pCons = new PositionConstraints();
pCons.x = 120;
pCons.y = 160;
TextBox1 = new TextField("48,120");
posLayout.setConstraints(TextBox1, pCons);
add(TextBox1);
setTitle("Document1");
setSize(90,90);
setVisible(true);
addWindowListener (new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
public void actionPerformed (ActionEvent e) {
if (e.getSource() == Command1) {
try {
     System.out.println("button clicked");
Command1Method();
catch (Exception ex1) {
ex1.printStackTrace(System.out);
public void Command1Method() throws SQLException, ClassNotFoundException {
Statement stmt = null;
ResultSet rset = null;
Connection conn = null;
String query = "select BONUS.ENAME from BONUS where BONUS.JOB like '%MAN%'";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//Class.forName("jdbc.odbc.JdbcOdbcDriver");
//jdbc.odbc.JdbcOdbcDriver
catch (ClassNotFoundException ce) {
System.out.println("Unable to Load Driver Class "); }
try {
conn = DriverManager.getConnection(url, user, password);
stmt = conn.createStatement(); }
catch (SQLException se) {
se.printStackTrace(System.out); }
try {
rset = stmt.executeQuery(query); }
catch (SQLException se) {
se.printStackTrace(System.out); }
while (rset.next()) {
TextBox1.setText(rset.getString("ENAME"));
try {
stmt.close();
conn.close();
rset.close(); }
catch (SQLException se) {
System.out.println("Error in Closing Database Connection" + se.getMessage());
se.printStackTrace(System.out); }
public static void main (String[] args) {
new Document1();
private String url = "jdbc:oracle:thin:@localhost:1521:KAPIL";
     private String user = "scott";
     private String password = "tiger";
This has been the bain of my life for the past few weeks/month so any help is much appreciated

Similar Messages

  • Problem with classpath for XP

    i've made a java applet with three classes, two of which are classes to construct variables needed for the main interface to work. but the interface class cannot recognise that the other two classes exist. it gives out the cannot resolve system error. i know that there is no problem with the program syntax (or which directory they are in) because it compiles on other computers and i can compile the individual classes on my sustem. i have made numerous one class programs before so the compiler definitely works in some situations. i'm thinking then that the problem must be with my jdk in some way. i've tried re-installing my jdk and installing a different jdk but stil no joy. someone mentioned to me it could be something to do with how the classpath is set up but this is something i'm a bit unsure about, i know though that XP is slightly different to the other windows o/s. any advice would be much appreciated.

    My Windows is not English so I'm not sure whether it's exactly the same:
    Start>Configuration>System>Environment variables
    If there is a variable with the name "CLASSPATH" (system variables) look if . is in your classpath. If not, add to the classpath ";." . And if there is no CLASSPATH variable, add it (and add the value . to it).
    I hope it helps.

  • Problems with CLASSPATH in a executable jar file

    Hi there
    I'm having a problem that I don't know how to solve. My generalq uestion is:
    "Why isn't my CLASSPATH (java.class.path) forwarded into ar unnable class inside a jar file?"
    The situation is:
    I have made a runnable jar file containing an ant build.xml file, a jar file containing some patch files, and a class called AntLoader.class. AntLoader are the file that are executed (inserted into the manifest). This works. The class are executed, but it can't find the package needed for starting ant.
    ant.jar is in my CLASSPATH, and therefore everything works fine if I'm running AntLoader outside the jar file.
    I know that I can use different ClassLoader classes for dynamicly loading of a class, but then I need a path to where ant.jar is located. And then again my system wont be general. The jar file is supposed to be distributed as a system patch to customers. And their location of where ant is installed will not be the same.
    So what I'm looking for is a way to pass my CLASSPATH from my environment on to a jar file. Is that possible?
    running java -classpath "${CLASSPATH}" -jar cpc.jar doesn't help at all. The java.class.path is still set to cpc.jar when I'm executing the AntLoader class inside cpc.jar.
    Can anyone please help me?
    Brgds
    Jakob

    've found the solution to the problem. You have to use the -Xbootclasspath/a parameter when running java.
    Example on unix:
    java -Xbootclasspath/a:${CLASSPATH} -jar test.jar
    Brgds
    Jakob

  • Problems with classpath and accessing a specific file

    I'm currently running an application using NetBeans (I know this is the Sun Forum but maybe someone can help). For those who aren't familiar with this IDE, whenever a project is created, a ProjectName folder is also created. Inside that folder are 5 new folders (*build*, dist, nbproject, src and test) as well as 2 new files (*build.xml*, manifest.mf). The dist folder contains the *.jar* file.
    Seeing that this is an audio application, I am constantly working with audio files. In the ProjectName folder, I've created a sixth folder (*audiofiles*) were I load and save such audio files. To access a specific audio file, I do the following:
    File audioExample = File("audiofiles" + File.separator + "audio.wav");When I run the project from the IDE there doesn't seem to be a problem. However, when I try to run the project by simply double-clicking the *.jar* file in the dist folder, the audio files can't be accessed. In order to be able to access them, I need to change the path:
    File audioExample = File("C:\...\ProjectName\audiofiles\audio.wav");This seems to solve the problem temporarily, but if I decide to change to project folder location, I also need to change the path.
    QUESTION:
    What is the best way to access files so that they are not dependent on where the project folder is located? Do I need to modify the classpath or simply write the path in File(...) in a specific way? If I need to modify the classpath, how can I do so in Netbeans?
    Thanks in advance.

    DrClap,
    Thanks for the reply. To answer your questions:
    Naturally that depends on where you DO want to load from. Are the files in the classpath? Are they in the current working directory?
    Some other directory where you can ask the user to point to? On a different computer?The audio files are located in a created folder in the IDE project folder. I know you mentioned that I should stop thinking about this as an IDE project but I don't know any other way to think about it. I'm kinda new to Java, and the only way I've learned how everything is structured is through the IDE project structure. I'm realizing that this is probably not the best way to go about as it doesn't allow me to have a good understanding of the Java file structure. What changes do I need to make in the way I view my IDE project to make it more into a deployed version?
    I'm also having a hard time understanding the classpath concept. I've been under the impression that the classpath was simply the location of the packages and classes of a specific application. How could I check if the audio files are in the classpath?
    Thanks in advance.

  • Problems in Classpath and Path 's variables setting in Windows XP

    Here is my drive structure in my PC:
    1. hard drive (primary slave, Partition: C and E where E boot Windows XP
    2. Hard drive 2 (Primary Master), Drive letter: D
    Although my default boot directory is E (for strange reason, i like to keep
    that way for now), I installed other programs in C and D drive dues drive
    space factors.
    So My java sdk1.4.2_02 has been installed in C:\Java_home directory, the
    following is my Classpath and Path values:
    (CLASSPATH Variables)
    Classpath=.;
    c:\java_home\j2sdk1.4.2_02;
    e:\Program Files\java\j2re1.4.2_02;c:\java_home; c:\java_home\j2sdk1.4.2_01
    \lib;e:\Program Files\java; e:\Program Files\java web start;c:\java_home\j2
    sdk1.4.2_02\jre\lib;c:\java_home\java\petstore1.3.2\src\lib\jst1;
    (PATH variables)
    c:\java_home\j2sdk1.4.2_01\bin;C:\java_home;e:\Pr
    ogram Files\java;c:\java_home\jdk1.4.2_2\bin;E:\Program Files\Oracle\jre\1.
    1.8\bin;E:\WINDOWS\system32;E:\WINDOWS;E:\WINDOWS\system32\WBEM;E:\
    Program Files\Support Tools\;
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    Path=D:\oracle\ora92\bin;E:\Program Files\Oracle\jre\1.3.1\bin;
    My Fruit txt and Fruit.java file is located in my c:\java_home folder
    when I try to compile the my file as <c:\java_home\javadoc Fruit.java), it
    gives me the error message<'javac' is not recognized as an internal or
    external command,operable program or batch file.>
    however, I can compile the Fruit file from C:\java_home\jdk1.4.2_2
    \bin\javadoc Fruit.java; with out any problem of course I have to copy the
    Fruit.java file at the C:\java_home\jdk1.4.2_2\bin\javadoc Fruit.java
    folder.
    I am requesting u please help or advise me to correct my mistakes
    Ely
    [email protected]

    I must confess that I am totally unable to understand what your PATH is set to. The error that you see,
    <'javac' is not recognized as an internal or external command,operable program or batch file.>
    is due to a missing or incorrectly set PATH. It is used by Windows to find executable file (like javac.exe) that you have added to the computer. Item #5 on this page gives you instructions on how to set it: http://java.sun.com/j2se/1.4.2/install-windows.html
    As for the setting of the CLASSPATH, you seem to have a number of different versions of java (1.4.2_02, 1.4.2_01, 1.4.2_2, and 1.1.8) and I doubt that these are all valid. You are also using an unusual syntax C:\java_home\jdk1.4.2_2\bin\javadoc Fruit.java and I wonder if that is really C:\java_home\jdk1.4.2_2\bin\javadoc\Fruit.java? I think the best action is to point you to Sun's instructions and information about setting and using the CLASSPATH.
    The CLASSPATH is a set of pointers that is used by Java to find the files that YOU (not Java) create and want compiled and/or run.
    Setting the Classpath:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
    [NOTE: always start your classpath with ".;" which means the current directory. See my classpath, below]
    How Classes are Found:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html
    Examples:
    This is my path
    PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\BATCH;C:\J2SDK1.4.2_01\BIN;C:\PROGRA~1\UTILIT~1;C:\PROGRA~1\WIN98RK
    This is my classpath
    CLASSPATH=.;C:\mjava;C:\mnrx;C:\NetRexx\lib\NetRexxC.jar;C:\j2sdk1.4.2_01\lib\tools.jar;C:\NetRexx\NrxRedBk

  • Problems with classpath and comiling an easy program

    Hello everyone:
    I have downloaded jsdk1.3.1_03, (Windows xp)? what do i type in the class path?
    Once I am done with setting the classpath. I typed the helloworld program, and it give me an error specified path not found).
    Please help, through this.
    Sincerely
    Johanna

    it is problems with compiling and running!!! ,
    everytime I try to comile the helloworld program, it
    state an error like :specific path not found. I set
    the path and classpath to C:\jsdk1.3.1\bin
    is that correct? If you installed the developer's kit into c:\jsdk1.3.1 then that is correct. You need to include the directory where you installed java. Typically, that is c:\jdk1.3.1 for example (and add \bin). You can try to "cd c:\jsdk1.3.1\bin" and try javac again. You must have NO spaces in your Path setting.

  • Problem of classpath

    Hi,
    I have to face a very stupid problem I can't fix by myself.
    I run under Windows Me and I had a few minutes ago to add some .jar files to my classpath.
    I don't know what error I did during this tranformation, but now, every time I open a Dos-window, after the path of the current folder, there is a ; I can't absolutely not remove.
    By the way, every time I open a Dos-window, a .temp file appears in my c:\ directory too, something that did not happen before.
    Here's my autoexec.bat file:
    SET COMSPEC=C:\WINDOWS\COMMAND.COM
    SET windir=C:\WINDOWS
    SET winbootdir=C:\WINDOWS
    SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;c:\jdk1.3\bin
    SET CLASSPATH=C:\tomcat\common\lib\servlet.jar;C:\xalan\bin\xalan.jar;C:\xalan\bin\xercesImpl.jar;C:\xalan\bin\xml-apis.jar;C:\xalan\bin\xalansamples.jar;C:\xalan\bin\xalanservlet.jar;C:\xalan\bin\bsf.jar;C:\xalan\bin\js.jar;c:\xalan\samples\ApplyXPath;C:\fop\build\fop.jar;C:\fop\lib\avalon-framework-4.0.jar;c:\fop\lib\xalanj1compat.jar;c:\fop\lib\batik.jar;c:\fop\lib\ant.jar;c:\fop\lib\logkit-1.0.jar;c:\java;c:\soap-2_2\lib\soap.jar;.;C:\jdk1.3\lib\tools.jar;c:\tomcat\common\lib\mail.jar;c:\tomcat\common\;C:\Mes_documents\XML\semanticWeb\Jena\bis\Jena-1.4.0\lib\jena.jar
    SET JAVA_HOME=c:\jdk1.3
    SET CATALINA_HOME=C:\tomcat
    SET PROMPT=$p$g
    SET TEMP=C:\WINDOWS\TEMP
    Thanks a lot for helping me,
    Steevy.

    Please, it's very urgent, I'm completely locked with this difficulty.
    DId anybody face the same problem?
    The question is:
    What can be the cause of having automticcaly a ; in a DOs-Window when we open it?
    Thanks for your answers,
    Steevy.

  • Execute an external java program with Runtime, problem with classpath

    Hi,
    I m calling an external java program by the command:
    Runtime.getRuntime().exec("java -classpath \"library/*\" org.mypackage.TestMainProgram param1 c:/input/files c:/output/files");All my classes are stored in the relative directory "library", and it contains ONLY .jar files. However, I keep getting errors like:
    "java.lang.NoClassDefFoundError: library/antlr/jarCaused by: java.lang.ClassNotFoundException: library.antlr.jar     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)     at java.security.AccessController.doPrivileged(Native Method)     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)Could not find the main class: library/antlr.jar. Program will exit.Exception in thread "main" where "antlr.jar" is a jar file in "library". It is there but still the program keeps complaining it cannot be found. The problem applies to any jars in "library", ie.., if i have "mylib.jar" then it will complain "NoClassDefFoundError: library/mylib/jar".
    Could anyone give some pointers please?
    Many thanks!
    Edited by: 836590 on 14-Feb-2011 09:03

    836590 wrote:
    Hi,
    I m calling an external java program by the command:
    Runtime.getRuntime().exec("java -classpath \"library/*\" org.mypackage.TestMainProgram param1 c:/input/files c:/output/files");All my classes are stored in the relative directory "library", and it contains ONLY .jar files. However, I keep getting errors like:
    "java.lang.NoClassDefFoundError: library/antlr/jarCaused by: java.lang.ClassNotFoundException: library.antlr.jar     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)     at java.security.AccessController.doPrivileged(Native Method)     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)     at java.lang.ClassLoader.loadClass(ClassLoader.java:252)     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)Could not find the main class: library/antlr.jar. Program will exit.Exception in thread "main" where "antlr.jar" is a jar file in "library". It is there but still the program keeps complaining it cannot be found. The problem applies to any jars in "library", ie.., if i have "mylib.jar" then it will complain "NoClassDefFoundError: library/mylib/jar".
    Could anyone give some pointers please?
    Many thanks!
    Edited by: 836590 on 14-Feb-2011 09:03First, if you run from the command line
    java -classpath "library/*" org.mypackage.TestMainProgram param1 c:/input/files c:/output/filesfrom the parent directory of library, does it work?
    Despite what I said to Kayaman about Runtime.exec not expanding the asterisk, it looks like that's what's happening, so that you're getting
    java -claspath library/aaaa_something_before_antlr.jar library/antlr.jar library/bbb.jar library/ccc.jar  org.mypackage.TestMainProgram param1 c:/input/files c:/output/filesThat is, it *is* expanding the asterisk to a list of files in the directory, and the first one is being taken as the classpath, and the second one--library/antlr.jar is being taken as the class to execute. I'm certain this doesn't happen on Linux, so it must be a Windows thing.
    Two suggestions:
    1) Try single quotes instead of double.
    2) Try the exec that takes an array
    Runtime.getRuntime().exec(new String[] {"java", "-classpath", "'library/*'", "org.mypackage.TestMainProgram", "param1", "c:/input/files", "c:/output/files");Edited by: jverd on Feb 14, 2011 9:41 AM

  • OIM 11.1.1.3 Adapter compilation problem, missing classpath entries

    Hi all,
    I have installed MSAD connector 9.1.1.7.0 to my OIM 11.1.1.3 box. All the check-marks on the installation page were green.
    But in the logs I see no adapters were successfully compiled:
    <Oct 12, 2011 3:57:38 PM MSD> <Error> <XELLERATE.ADAPTERS> <BEA-000000> <Class/Method: tcAdpUtils/compileAdapter encounter some problems: Could not compile adapter : adpADCSCHECKPROCESSPARENTORG>
    <Oct 12, 2011 3:57:38 PM MSD> <Error> <XELLERATE.ADAPTERS> <BEA-000000> <Class/Method: tcAdpUtils/compileAdapter encounter some problems: Compile failed on Wed Oct 12 15:57:38 MSD 2011
    /tmp/oracle/oim/adapters/adpADCSCHECKPROCESSPARENTORG.java:4: package com.thortech.xl.dataobj does not exist
    import com.thortech.xl.dataobj.*;
    /tmp/oracle/oim/adapters/adpADCSCHECKPROCESSPARENTORG.java:13: package com.thortech.xl.dataobj.util does not exist
    The beginning of the Java file to compile from same logs looks like following:
    1: /* Copyright (c) 2001 - 2007, Oracle Corporation. All rights reserved.
    2: */
    3: package com.thortech.xl.adapterGlue.ScheduleItemEvents;
    4: import com.thortech.xl.dataobj.*;
    5: //import com.thortech.xl.adapterGlue.*;
    6: //import com.thortech.xl.dataobj.tcDataSet;
    7: import java.io.IOException;
    8: import java.util.*;
    9: import java.io.FileWriter;
    10: import java.io.File;
    11: import java.sql.Timestamp;
    12: import java.text.DateFormat;
    13: import com.thortech.xl.dataobj.util.tcAdapterTaskException;
    14: import com.thortech.xl.dataobj.util.;*
    15: import com.thortech.xl.dataobj.util.tcJarEntryClassLoader;
    16: import com.thortech.xl.remotemanager.*;
    17: import java.rmi.*;
    18: import java.net.URL;
    19: import java.lang.reflect.Constructor;
    20: import java.lang.reflect.Method;
    21: import java.lang.reflect.Modifier;
    22: import java.lang.reflect.InvocationTargetException;
    23: import java.lang.reflect.Field;
    24: import java.net.*;
    The compilation command line from same logs looks like following:
    javac -classpath /odrive/oracle/oim11g_MWH/wlserver_10.3/server/ext/jdbc/oracle/11g/ojdbc6dms.jar:/odrive/oracle/oim11g_MWH/Oracle_SOA1/soa/modules/user-patch.jar:/odrive/oracle/oim11g_MWH/Oracle_SOA1/soa/modules/soa-startup.jar::/odrive/oracle/oim11g_MWH/patch_wls1033/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/odrive/oracle/oim11g_MWH/patch_ocp353/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/usr/lib/jvm/java-6-sun-1.6.0.24/lib/tools.jar:/odrive/oracle/oim11g_MWH/wlserver_10.3/server/lib/weblogic_sp.jar:/odrive/oracle/oim11g_MWH/wlserver_10.3/server/lib/weblogic.jar:/odrive/oracle/oim11g_MWH/modules/features/weblogic.server.modules_10.3.3.0.jar:/odrive/oracle/oim11g_MWH/wlserver_10.3/server/lib/webservices.jar:/odrive/oracle/oim11g_MWH/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/odrive/oracle/oim11g_MWH/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:/odrive/oracle/oim11g_MWH/Oracle_SOA1/soa/modules/oracle.soa.common.adapters_11.1.1/oracle.soa.common.adapters.jar:/odrive/oracle/oim11g_MWH/oracle_common/soa/modules/commons-cli-1.1.jar:/odrive/oracle/oim11g_MWH/oracle_common/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar:/odrive/oracle/oim11g_MWH/Oracle_IDM1/oam/agent/modules/oracle.oam.wlsagent_11.1.1/oam-wlsagent.jar:/odrive/oracle/oim11g_MWH/oracle_common/modules/oracle.xdk_11.1.0/xsu12.jar:/odrive/oracle/oim11g_MWH/modules/features/weblogic.server.modules.xquery_10.3.1.0.jar:/odrive/oracle/oim11g_MWH/Oracle_SOA1/soa/modules/db2jcc4.jar:/odrive/oracle/oim11g_MWH/user_projects/domains/oim11g_domain/config/soa-infra:/odrive/oracle/oim11g_MWH/Oracle_SOA1/soa/modules/fabric-url-handler_11.1.1.jar:/odrive/oracle/oim11g_MWH/Oracle_SOA1/soa/modules/quartz-all-1.6.5.jar:/odrive/oracle/oim11g_MWH/Oracle_SOA1/soa/modules/oracle.soa.fabric_11.1.1/oracle.soa.fabric.jar:/odrive/oracle/oim11g_MWH/Oracle_SOA1/soa/modules/oracle.soa.adapter_11.1.1/oracle.soa.adapter.jar:/odrive/oracle/oim11g_MWH/Oracle_SOA1/soa/modules/oracle.soa.b2b_11.1.1/oracle.soa.b2b.jar:/odrive/oracle/oim11g_MWH/Oracle_IDM1/server/lib/oim-manifest.jar:/odrive/oracle/oim11g_MWH/oracle_common/modules/oracle.jrf_11.1.1/jrf.jar:/odrive/oracle/oim11g_MWH/wlserver_10.3/common/derby/lib/derbyclient.jar:/odrive/oracle/oim11g_MWH/wlserver_10.3/server/lib/xqrl.jar:.:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar -d /tmp/oracle/oim/adapters /tmp/oracle/oim/adapters/adpADCSCHECKPROCESSPARENTORG.java
    As you may see, neither import com.thortech.xl.dataobj nor import com.thortech.xl.remotemanager are defined in classpath.
    Does anybody know where could I configure the adapter compilation classpath?

    adding the following line to the server launch script did the trick:
    export CLASSPATH=$CLASSPATH:$OIM_ORACLE_HOME/server/lib/xlDataObjects.jar:$OIM_ORACLE_HOME/server/lib/xlRemoteManager.jar

  • Problems setting classpath...

    hello guys...i am having a problem with what should be a very simple operation...
    the classes i define are stored in the classes directory..inside, each package has its own subdirectory...
    classes
    beans
    User.class
    Cart.class
    i have tried to change my classpath to reflect this location and instruct the compiler as to where to find those classes..
    i have used the set Classpath command...
    SET CLASSPATH=.;C:\Tomcat\common\lib\servlet-api.jar;C:\Tomcat\common\lib\mysql-connector-java-3.1.13-bin.jar;
    C:\Tomcat\webapps\theagent\WEB-INF\classes beans.User;
    but when i try to import beans.User in another class..it doesnt compile and tells me that the package doesnt exist...
    please help....what else do i need to check to make sure the configuration is as it should be...
    p.c User.java started with package beans;
    thanks

    That is correct because your beans.User class doesn't contain a
    public static void main(String[] args) method, iow you can't run it by itself.i dont want to run the class by itself... i just want to import beans.User;
    but it says that no such package exists...Then you have to be a bit more clear. You mentioned this command line:java -classpath C:\Tomcat\common\lib\servlet-api.jar;
    C:\Tomcat\common\lib\mysql-connector-java-3.1.13-bin.jar;
    C:\Tomcat\webapps\theagent\WEB-INF\classes beans.User;This sets the classpath pointing to two jars and a 'classes' directory.
    You're trying to run the 'beans.User' class which I presume is stored
    in a subdirectory of that 'classes' directory.
    The java command works like this:java -classpath <jars and dirs here> package.YourClass... so you were trying to run your beans.User class all by itself. It doesn't
    contain a main method hence the runtime diagnostic. btw, I don't know
    why you appeded that whole thing with a semicolon.
    kind regards,
    Jos

  • Probleme about classpath

    Hi ( again i know ... lol )
    I go through the forum to understant the classpath problem but some points remain unclear to me ...
    I have an application , my main class is in a directory and i use in this main other classes that are contained in sub-directory parcours.
    So to compile and execute the only solution that i have found is to type :
    javac -classpath .;./parcours *.java
    java -classpath .;./parcours Mainclass
    Is there another solution , for exemple to specify directly in the source of my main class the path of the parcours classes ( some kinf of import or somethin ... ) or maybe somethin else ...
    Thx.

    Have you understood correctly the concept of packages? Read the Java Tutorial - http://java.sun.com/docs/books/tutorial/java/interpack/packages.html .
    But if you can run your app with so few parameters given, you are lucky.
    Real world apps usually have real big classpath strings - I use the Sun iPlanet 6.5 product and the classpath I must set in the iPlanet Registry is :
    C:\jar\xerces.jar;C:\iPlanet\ias6\ias\APPS\soap-services;C:\oracle\ora90\jdbc\lib\classes12.zip;C:\iPlanet\ias6\ias\classes\java\javax.jar;C:\iPlanet\ias6\ias\usr\java\lib\tools.jar;C:\iPlanet\ias6\ias\classes\java\activation.jar;C:\iPlanet\ias6\ias\classes\java\servlet.jar;C:\iPlanet\ias6\ias\classes\java\mail.jar;C:\iPlanet\ias6\ias\classes\java\jdbc20.jar;C:\iPlanet\ias6\ias\classes\java\iascli.jar;C:\iPlanet\ias6\ias\classes\java\kfcjdk11.jar;C:\iPlanet\ias6\ias\classes\java;C:\iPlanet\ias6\ias\classes\java\ldapjdk.jar;C:\iPlanet\ias6\ias\classes\java\ldapfit.jar;C:\iPlanet\ias6\ias\classes\java\ldapsp.jar;C:\iPlanet\ias6\ias\APPS;C:\iPlanet\ias6\ias\classes\java\ktjdk11.jar;C:\iPlanet\ias6\ias\classes\java\kadmin.jar;C:\iPlanet\ias6\ias\classes\java\tomcat\jasper.jar;C:\iPlanet\ias6\ias\classes\java\jaxp\jaxp.jar;C:\iPlanet\ias6\ias\classes\java\jaxp\parser.jar;C:\iPlanet\ias6\ias\STARTUPCLASS\startup.jar;C:\iPlanet\ias6\ias\classes\java\jts.jar;C:\iPlanet\ias6\ias\classes\java\jms.jar;C:\iPlanet\ias6\ias\classes\java\jmq.jar;C:\iPlanet\ias6\pointbase\network\lib\pbnetwork35GA.jar;C:\iPlanet\ias6\pointbase\client\lib\pbclient35GA.jar;C:\iPlanet\ias6\ias\classes\java\log4j-1.2.7.jar;C:\iPlanet\ias6\ias\classes\java\commons-logging.jar;C:\iPlanet\ias6\ias\classes\java\framework-1.1.0.jar;C:\iPlanet\ias6\ias\classes\java\tomcat\jasper_properties.jar;C:\iPlanet\ias6\ias\classes\java\jts_properties.jar;C:\iPlanet\ias6\ias\classes\java\kadmin_properties.jar;C:\iPlanet\ias6\ias\classes\java\kfcjdk11_properties.jar

  • Problem about Classpath configuration!

    I have written some EJB code and need the j2ee.jar to compile it.
    But when I compile it ,An error happened:
    javax.ejb.* doesn't existBut I have set the Classpath like below:
    .;c:\j2sdk1.4.1_01\lib;c:\Sun\AppServer\lib\j2ee.jar;c:\Sun\AppServer\libThe question is when I copy the j2ee.jar file into c:\j2sdk1.4.1_01\lib which contain the java core class.
    It can't work neither.
    But finally when I decompress it into javax/ejb/*.*
    The compilation will succeed.
    Have you encountered such a problem.
    Thanks for help!!!

    You should not unpack the contents of the j2ee.jar.
    You shouldn't be putting it in the J2SDK/lib directory, either.
    Make sure that the javax.ejb.* package does indeed come in that JAR. Maybe it's in another one. Be sure that you've got it before you panic.
    I'd recommend setting the CLASSPATH without resorting to a system environment variable:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html

  • Problems with classpath in Fedora core 4

    hello
    i want to set class path in Fedora core 4 so that my jmf2.1.1e apis is properly taken during compilation and runtime. in short; i want to install jmf into Linux distro sothat i can compile and run its applications.
    also i have a jar file of a jmf media player. now i need to know how to run it from a jar into my Fedora core distro...
    i have downloaded the linux performance pack from sun site and also read the installation notes but that really doesnt help. they say to apply the command 'setenv' into the shell to set environment var but that doesnt work i have seen.
    please help!

    've found the solution to the problem. You have to use the -Xbootclasspath/a parameter when running java.
    Example on unix:
    java -Xbootclasspath/a:${CLASSPATH} -jar test.jar
    Brgds
    Jakob

  • Problems using classpath

    Hi !
    I'm using java on win98.
    I'm trying to modify class path and source path.
    I was told to write:
    set CLATHPATH=path1;path2
    and then compile by:
    javac -d classes sources\path
    when trying to do it it says:
    the classes directory does not exit.
    what is the problem ?
    Thank you

    Hi !
    I'm using java on win98.
    I'm trying to modify class path and source path.
    I was told to write:
    set CLATHPATH=path1;path2
    and then compile by:
    javac -d classes sources\path
    when trying to do it it says:
    the classes directory does not exit.
    what is the problem ?
    Thank you
    it should read:
    set CLASSPATH=path1;path2
    where path1 and path2 are valid paths to be used in locating classes for execution. As an example you might use something like:
    set CLASSPATH=.;c:\;d:\;c:\javaclasses
    Regards,
    Mark

  • Problem in classpath setting!!please help urgent

    hi,
    i am using BEA weblogic server 9.0.i created a new domain names servletproj.i have created directory webapp under applications dir.
    i.e C:\bea\user_projects\domains\servletproj\applications\webapp
    i have created a directory srtucture as webapp\WEB-INF\web.xml
    and webapp\WEB-INF\classes\HelloClientServlet.class
    i am able to start and shut down the server.i compiled the servlet program successfully.
    but i want to run the program .i don't know how to set the classpath and path variables .please help me.please explain in simple steps.i would like to set the path in command line.
    bye.

    Hi Kristoper,
    No..that Vo is based on some EO..why i am using the row.setAttribute() is...the bid number is coming from some other page...and i need to insert it in table..
    and except the bid number..other values are coming from the page...
    Thank you

Maybe you are looking for