when i set a classpath variable a very easy program can't find it'sown class

S

Selmar

Hi,

I have the following, i think very easy to solve, problem.

I try to run a very simple program (look below, it's just a test program).

It compiles very well with “javac TestClass.java”
But when i want to run it i get the following error
java TestClass
java.lang.ClassNotFoundException: TestClass
at kaffe.lang.AppClassLoader.findClass (AppClassLoader.java:296)
at java.lang.ClassLoader.loadClass (ClassLoader.java:142)

I only get this message with in my /etc/profile the following line:

export
CLASSPATH=/usr/java/j2sdk1.4.2_04/jre/lib/ext/biojava-1.30-jdk14.jar:/usr/java/j2sdk1.4.2_04/jre/lib/ext/bytecode-0.91.jar:/usr/java/j2sdk1.4.2_04/jre/lib/ext/jakarta-regexp.jar:/usr/java/j2sdk1.4.2_04/jre/lib/ext/xerces.jar:/usr/bio-java/demos:/usr/MySQL_java_driver/mm.mysql-2.0.14

without this line it works right. But i need this line for other things.
Does anyone knows the solution for this problem?

Tanks in advance,

Selmar.

The file i compile and try to run:
public class TestClass
{

public static void main (String[] args)
{
int oranges=5;
int apples=10;
int fruit=0;
fruit=oranges+apples;

System.out.println("A totallly fruity program");
System.out.println(fruit);
}

}

environment variable with that line

LC_PAPER=nl_NL
LESSKEY=/etc/.less
LC_ADDRESS=nl_NL
KDE_MULTIHEAD=false
HOSTNAME=bioinf-235-183
LC_MONETARY=nl_NL
TERM=xterm
SHELL=/bin/bash
DESKTOP_STARTUP_ID=bioinf-235-183;1089373632;21204;3898
XDM_MANAGED=/var/run/xdmctl/xdmctl-:0,maysd,mayfn,sched,rsvd
HISTSIZE=1000
TMPDIR=/home/selmar/tmp
GTK2_RC_FILES=/usr/share/themes/Galaxy/gtk-2.0/gtkrc:/etc/gtk-2.0/gtkrc:/home/selmar/.gtkrc-2.0:/home/selmar/.kde/share/config/gtkrc
GS_LIB=/home/selmar/.fonts
GTK_RC_FILES=/usr/share/themes/Galaxy/gtk/gtkrc:/etc/gtk/gtkrc:/home/selmar/.gtkrc:/home/selmar/.kde/share/config/gtkrc
WINDOWID=52428809
LC_NUMERIC=nl_NL
QTDIR=/usr/lib/qt3/
KDE_FULL_SESSION=true
USER=selmar
LC_TELEPHONE=nl_NL
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:eek:r=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
XCURSOR_SIZE=
SESSION_MANAGER=local/bioinf-235-183:/tmp/.ICE-unix/3919
NLSPATH=/usr/share/locale/%l/%N
PATH=/usr/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games:/home/selmar/bin
DESKTOP_SESSION=01KDE
MAIL=/var/spool/mail/selmar
LC_MESSAGES=en_US
LC_COLLATE=en_US
LC_IDENTIFICATION=nl_NL
SECURE_LEVEL=2
PWD=/home/selmar
INPUTRC=/etc/inputrc
XMODIFIERS=@im=none
JAVA_HOME=/usr/java/j2re1.4.2_04/bin
HELP_BROWSER=kfmclient openProfile webbrowsing
LANG=en_US
LC_MEASUREMENT=nl_NL
HISTCONTROL=ignoredups
HOME=/home/selmar
SHLVL=2
LANGUAGE=en_US:en
GCONF_TMPDIR=/tmp
XCURSOR_THEME=default
LOGNAME=selmar
LESS=-MM
TMP=/home/selmar/tmp
LC_CTYPE=en_US
LESSOPEN=|/usr/bin/lesspipe.sh %s
DESKTOP=kde
BROWSER=kfmclient openProfile webbrowsing
DISPLAY=:0.0
LC_TIME=en_US
G_BROKEN_FILENAMES=1
LC_NAME=nl_NL
XAUTHORITY=/home/selmar/.Xauthority
_=/usr/bin/env

Environment variable with the line in /etc/profile

LESSKEY=/etc/.less
LC_PAPER=nl_NL
KDE_MULTIHEAD=false
LC_ADDRESS=nl_NL
LC_MONETARY=nl_NL
HOSTNAME=bioinf-235-183
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
XDM_MANAGED=/var/run/xdmctl/xdmctl-:0,maysd,mayfn,sched,rsvd
GTK2_RC_FILES=/usr/share/themes/Galaxy/gtk-2.0/gtkrc:/etc/gtk-2.0/gtkrc:/home/selmar/.gtkrc-2.0:/home/selmar/.kde/share/config/gtkrc
TMPDIR=/home/selmar/tmp
GTK_RC_FILES=/usr/share/themes/Galaxy/gtk/gtkrc:/etc/gtk/gtkrc:/home/selmar/.gtkrc:/home/selmar/.kde/share/config/gtkrc
GS_LIB=/home/selmar/.fonts
WINDOWID=31457285
LC_NUMERIC=nl_NL
QTDIR=/usr/lib/qt3/
KDE_FULL_SESSION=true
USER=selmar
XCURSOR_SIZE=
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:eek:r=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
LC_TELEPHONE=nl_NL
SESSION_MANAGER=local/bioinf-235-183:/tmp/.ICE-unix/3919
KONSOLE_DCOP=DCOPRef(konsole-3934,konsole)
NLSPATH=/usr/share/locale/%l/%N
MAIL=/var/spool/mail/selmar
DESKTOP_SESSION=01KDE
PATH=/usr/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games:/home/selmar/bin
LC_MESSAGES=en_US
SECURE_LEVEL=2
LC_IDENTIFICATION=nl_NL
LC_COLLATE=en_US
KONSOLE_DCOP_SESSION=DCOPRef(konsole-3934,session-20)
INPUTRC=/etc/inputrc
PWD=/home/selmar
JAVA_HOME=/usr/java/j2re1.4.2_04/bin
XMODIFIERS=@im=none
LANG=en_US
HELP_BROWSER=kfmclient openProfile webbrowsing
LC_MEASUREMENT=nl_NL
HISTCONTROL=ignoredups
SHLVL=2
HOME=/home/selmar
LANGUAGE=en_US:en
XCURSOR_THEME=default
GCONF_TMPDIR=/tmp
TMP=/home/selmar/tmp
LESS=-MM
LOGNAME=selmar
CLASSPATH=/usr/java/j2sdk1.4.2_04/jre/lib/ext/biojava-1.30-jdk14.jar:/usr/java/j2sdk1.4.2_04/jre/lib/ext/bytecode-0.91.jar:/usr/java/j2sdk1.4.2_04/jre/lib/ext/jakarta-regexp.jar:/usr/java/j2sdk1.4.2_04/jre/lib/ext/xerces.jar:/usr/bio-java/demos:.
LC_CTYPE=en_US
LESSOPEN=|/usr/bin/lesspipe.sh %s
BROWSER=kfmclient openProfile webbrowsing
DESKTOP=kde
DISPLAY=:0
LC_TIME=en_US
G_BROKEN_FILENAMES=1
COLORTERM=
XAUTHORITY=/home/selmar/.Xauthority
LC_NAME=nl_NL
_=/usr/bin/env
 
M

Michael Borgwardt

Selmar said:
java.lang.ClassNotFoundException: TestClass
I only get this message with in my /etc/profile the following line:

export
CLASSPATH=/usr/java/j2sdk1.4.2_04/jre/lib/ext/biojava-1.30-jdk14.jar:/usr/java/j2sdk1.4.2_04/jre/lib/ext/bytecode-0.91.jar:/usr/java/j2sdk1.4.2_04/jre/lib/ext/jakarta-regexp.jar:/usr/java/j2sdk1.4.2_04/jre/lib/ext/xerces.jar:/usr/bio-java/demos:/usr/MySQL_java_driver/mm.mysql-2.0.14

The classpath is missing an entry for the current directory .
without this line it works right. But i need this line for other things.

You shouldn't need it. In fact, any use of the CLASSPATH environemnt variable
is discouraged. Instead, the -cp command line switch of the JVM should
be used so that each program gets the classpath it needs and only that.
 
S

Selmar

Michael said:
The classpath is missing an entry for the current directory .



You shouldn't need it. In fact, any use of the CLASSPATH environemnt
variable
is discouraged. Instead, the -cp command line switch of the JVM should
be used so that each program gets the classpath it needs and only that.

Thank you, this works!!
 

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

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,001
Latest member
Kendra00E1

Latest Threads

Top