• 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

newbie looking for some help

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have an issue, new to Java.
I'm trying to run java on the command line to insert some information into the database.

/usr/local/java/bin/java -classpath com/app/datur/ Blind
Exception in thread "main" java.lang.NoClassDefFoundError: Blind

/usr/local/java/bin/java com.app.datur.Blind
Exception in thread "main" java.lang.NoClassDefFoundError: com/app/datur/Blind

What does this mean?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a pain to get working some times.

1) Update your PATH so you don't have to specify the path to java.exe. I'm not sure if this is important, but might be if the JVM wants to use the path to find other parts of the JRE.

2) Point your classpath to the directory that contains the first part of your package name. In my case it's called "bin" and "com" is a subdirectory there.

3) Specify the full package & class name for your main class.

Here's how I start one of my programs. I use jars instead of a directory structure, but otherwise it's the same:

See if any of that helps
[ November 24, 2004: Message edited by: Stan James ]
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This means that Java can't find the class files with the information you gave it on the command line. Let's say your source files are somewhere in your home directory:



To compile and run, the commands would be:

cd ~/src/project1
/usr/local/java/bin/javac com/app/datur/Blind.java
/usr/local/java/bin/java com.app.datur.Blind

Also, make sure you have the package declaration in Blind.java:

package com.app.datur;
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

/usr/local/java/bin/java -classpath com/app/datur/ Blind
Exception in thread "main" java.lang.NoClassDefFoundError: Blind



If you are using Windows, try using \ instead of /.

Please check that Blind.class is actually in directory "com\app\datur".
Also, do a "dir" in Windows or "ls -l" in LINUX/UNIX just before you issue the java command and make sure that you see directory "com".
 
Glen Wilson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm on Solaris.

The full path to the Blind file is: /opt/application/test1/webapps/debatur/WEB-INF/classes/com/app/datur/Blind.class

file

package com.app.datur;

import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.sql.*;
import java.util.StringTokenizer;

import com.app.dat.ApplicationCon;
 
Glen Wilson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think I got it.
 
Glen Wilson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Except now I get

Exception in thread "main" com.dread.layer.DataException: Can't find DB Driver make sure it is on your classpath
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at com.dread.layer.ConnectionFactory.__beginFactory(ConnectionFactory.java:231)
at com.dread.layer.ConnectionFactory.loadFactory(ConnectionFactory.java:121)
at com.app.datur.Blind.main(Blind.java:5)

mysql driver is in /opt/application/test1/webapps/debatur/WEB-INF/lib
[ November 24, 2004: Message edited by: Glen Wilson ]
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you need to add the jar file that contains the mysql driver class to your classpath
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you need help with setting your CLASSPATH, check out this page on our friendly FAQ. Scroll down about half way for the instructions on how to do this in Linux. It should be similar in Solaris since it is basically a variant of Unix.

HTH

Layne
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic