?
Solved

How to correctly install Java 1.4.0_01

Posted on 2006-05-11
22
Medium Priority
?
350 Views
Last Modified: 2010-05-19
I have downloaded this java sdk: 1.4.0_01

However, when i try to run a .bat file that i have, it wont work, saying, "NoClassDefFoundError"

I am pretty sure i have to alter something in the autoexec.bat, which i have no idea where this is

I did have this 1.4.0_01 sdk working on my machine before, and i remember having to do something with the environment variable, but cant remember. I am using windows XP Pro

Any help as im sure this is not hard to solve
0
Comment
Question by:ab2ae
  • 10
  • 5
  • 5
  • +2
22 Comments
 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
ID: 16657769
you need to set your CLASSPATH environment variable to specify the location of your class files

http://mindprod.com/jgloss/classpath.html

"For NT/W2K/XP/W2K3, since there is no autoexec.bat, you have to preload the environment strings into the environment with Settings ? control panel ? system ? environment. You can use traditional BAT files to create them, then echo, copy and paste them into the permanent environment. Remember to click set before you click OK or your new settings will be discarded. Also see the rules above for dealing with directory of jar filenames containing blanks Alternatively always install your apps in directories without embedded spaces. Make sure you have no lead or trail spaces on the classpath as a whole. The control panel uses a microscopic unreadable font. To proofread, copy/paste to an editor. Beware of spurious spaces introduced by copy/pasting."
0
 
LVL 8

Expert Comment

by:colr__
ID: 16657971
You can also set the classpath in your batch file, like the following:

java -classpath "C:/mySoftware/root" TheProgram

I tend to use batch files a lot for this kind of thing to, and I personally find that setting the classpath in the batch file is easier than setting it in Windows itself.

colr__
0
 

Author Comment

by:ab2ae
ID: 16658108
To make things easier (hopefully) here are some details

My path is: C:\Documents and Settings\Desktop\Virtura

The .bat file is called: V19may

Objects your post confused me and colr i have no idea where and how to set the classpath in my batch file??!!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 8

Expert Comment

by:colr__
ID: 16658160
The batch file is just a text file with DOS code in it - open this up in Notepad and youll see somewhere a line saying java <yourapplicationname>

So, with your path above, youd want to use this instead:

java -classpath "C:\Documents and Settings\Desktop\Virtura" <yourapplicationname>

colr__
0
 

Expert Comment

by:borbjo
ID: 16658337
before you run your bat file, run this in DOS:

SET CLASSPATH=%CLASSPATH%;.;

The "." means that you add the current directory to your classpath. That's what the problem is here - you should always have the current directory in your classpath - thus you should always have . in your classpath ;-)
0
 

Author Comment

by:ab2ae
ID: 16658961
I went to the command prompt screen typed in SET CLASSPATH=%CLASSPATH%;.; then right-clicked on the .bat file and went to 'Edit'

Changed the path as follows: java -cp "C:\Documents and Settings\Desktop\Virtura" V19may.jar Screen

Still get the SAME error "NoClassDefFoundError"

This is a real pain to put it mildly :(
0
 
LVL 8

Expert Comment

by:colr__
ID: 16659051
Can you tell us the package statment your using? As well as the location and name of your main() class.

colr__
0
 

Author Comment

by:ab2ae
ID: 16659225
package statement?
0
 

Author Comment

by:ab2ae
ID: 16659250
I have changed the environment variables
PATH: C:\j2sdk1.4.0_01\bin
CLASSPATH: "C:\Documents and Settings\Barry\Desktop\Virtura"

still same error
0
 
LVL 8

Expert Comment

by:colr__
ID: 16659286
How many classes are in your application?
If more than one, are the all in the same folder?

Looking back at your first post -what exactly is your batch file supposed to be doing? I think we've been assuming its to run a java application, but Im now starting to wonder...

colr__
0
 

Author Comment

by:ab2ae
ID: 16659344
there are many classes, its an app i downloaded from a lecturer so i know it works as ive used it before. All i need to do is double-click the .bat file and it should run

The batch file is supposed to open up a class which serves as the main interface, as i said, i never wrote it

do u have an email address, i will send u the whole foler, it is DEFINATELY java
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16659620
Its against the site rules to post e-mail IDs on question-pages. Post the contents of the batch file here.
0
 

Author Comment

by:ab2ae
ID: 16659667
ive seen someone post an email address before!

Contents of batch file: java -cp V19may.jar Screen
0
 
LVL 8

Accepted Solution

by:
colr__ earned 1200 total points
ID: 16659734
ok, is V19may.jar in the same directory as your batch file?

If not, Ive seen this message before when running an application on an oldere JVM thatn what the application was compiled to.
To test this, run the batch file via dos - you should get a better error repport doing it that way.

colr__
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 600 total points
ID: 16659772
>> ive seen someone post an email address before!

The moderators delete it when they see it.

>> java -cp V19may.jar Screen

Yes, colr is right - you need V19may.jar in the same directory that contains the Screen.class file (I assume this is where you are running from), otherwise specify the full-path of the JAR file.
0
 

Author Comment

by:ab2ae
ID: 16659844
v19may IS the name of the batch file, i dont have a jar file in the folder. But why would it work before and i didnt have to change ANYTHING?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16659881
If there is no such jar which is needed, just try:

java Screen

- do it from the directory that contains the Screen.class file.
0
 

Author Comment

by:ab2ae
ID: 16660010
"- do it from the directory that contains the Screen.class file."

u mean change the contents of the .bat file?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16660024
Yes, because if the JAR is not required, then its a wrong command in the batch file.
0
 

Author Comment

by:ab2ae
ID: 16660053
tried it same error "NoClassDefFoundError"

ive had enough for one day 4hrs of wasted time im steaming at the ears, will be speaking to my lecturer tomorrow then will post solution hopefully

ARGH
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16664407
Could you tell us if the directory "C:\Documents and Settings\Desktop\Virtura" (from which you are running this batch-file) contains class-file?
0
 

Author Comment

by:ab2ae
ID: 16693018
OK guys, all i had to do was put the zipped version called 'version19may.jar' into the folder which contained the bat file.

Silly silly silly me, thansk for your help it was very good i learnt alot from this ;)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question