This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with installing JUnit on Red Hat

 
Unnsse Khan
Ranch Hand
Posts: 511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello...
I have been having trouble installing JUnit 3.8.1 on my Linux distribution, Red Hat 7.3, in particular.
Here's what I did:
1. I logged into Red Hat 7.3 as root
2. I downloaded JUnit3.1.8 frpm http://www.junit.org/index.htm
3. I followed the instructions by unzipping it, and I unzipped it at:
/usr/local/junit3.8.1
the junit.jar was located at
/usr/local/junit3.8.1/junit.jar
The instructions told me to append/add the junit3.8.1 directory and the junit.jar file to my CLASSPATH, so I did this:
cd /root
vim .bash_profile
and added accordingly (this is what my .bash_profile looks like):
------------------------------------------------------
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
JUNIT_HOME=$JUNIT_HOME:/usr/local/junit3.8.1/
JAVA_HOME=$JAVA_HOME:/usr/local/java/j2sdk1.4.0_01
J2EE_HOME=$J2EE_HOME:/usr/local/j2sdkee1.3.1
CLASSPATH=$CLASSPATH:.$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar:$J2EE_HOME/lib/j2ee.jar:$JUNIT_HOME/junit.jar:$JUNIT
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$J2EE_HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"
export USERNAME BASH_ENV PATH JAVA_HOME CLASSPATH J2EE_HOME JUNIT_HOME
--------------------------------------------------
And when I try to test it by typing in the following on the command line:
java junit.textui.TestRunner junit.samples.AllTests
It printed:
Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/TestRunner
Can anyone help me with this problem?
-Unnsse
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Unnsse Khan:
# User specific environment and startup programs
JUNIT_HOME=$JUNIT_HOME:/usr/local/junit3.8.1/
JAVA_HOME=$JAVA_HOME:/usr/local/java/j2sdk1.4.0_01
J2EE_HOME=$J2EE_HOME:/usr/local/j2sdkee1.3.1

I am not very familiar with unix environments, but I think those should read
# User specific environment and startup programs
JUNIT_HOME=/usr/local/junit3.8.1/
JAVA_HOME=/usr/local/java/j2sdk1.4.0_01
J2EE_HOME=/usr/local/j2sdkee1.3.1
[ December 04, 2002: Message edited by: Ilja Preuss ]
 
Brian McCallister
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, a couple recomendations:
1) Do not set up classpaths in your environment. Setting JAVA_HOME, ANT_HOME, JUNIT_HOME are okay, but setting up the actual CLASSPATH will bring you grief down the line when you think you are running against one library, but you are really running against a different version of it that was configured in your system classpath.
2) Ilja is exactly right, JAVA_HOME, ANT_HOME, JUNIT_HOME, JBOSS_HOME and those really shouldn't even be more than a single path. These do not represent search paths, they are absolute paths to these direcotries - so you don't want /path/one:/path/two you just want the path you wish to use.
-Brian
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Jakarta Forum (Open Source Projects).
 
Unnsse Khan
Ranch Hand
Posts: 511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed the .bash_profile like Ilja suggested, typing in:
java junit.textui.TestRunner junit.samples.AllTests
still doesn't work on Linux... Can anyone help me with this?
-Unnsse
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic