Errors on Run Java Application
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Errors on Run Java Application
I receive the following error from the DOS prompt when executing a compiled Java program.
*Exception in thread "main" java.lang.NoClassDefFoundError: TextPadTest
Press any key to continue...*
The code I'm trying to run is as follows:
public class TextPadTest{
public static void main(String[] args){
System.out.println("TestPad Test");
}
}
*Exception in thread "main" java.lang.NoClassDefFoundError: TextPadTest
Press any key to continue...*
The code I'm trying to run is as follows:
public class TextPadTest{
public static void main(String[] args){
System.out.println("TestPad Test");
}
}
Re: Errors on Run Java Application
Looks like your parameters are not correct. Are you running Win XP or 2000? Try the following, it should help:
Go to Configure->Preferences->Tools->Run Java Application
You should see a text box labeled "Paramaters", it probably says something like this:
$BaseName
But try changing it to:
-classpath . $BaseName
Also, change the parameters under Configure->Preferences->Tools->Compile Java
to the same thing.
That should clear that error, let me know if it helps.
John
Go to Configure->Preferences->Tools->Run Java Application
You should see a text box labeled "Paramaters", it probably says something like this:
$BaseName
But try changing it to:
-classpath . $BaseName
Also, change the parameters under Configure->Preferences->Tools->Compile Java
to the same thing.
That should clear that error, let me know if it helps.
John
Re: Errors on Run Java Application
I'm on XP, it still doesn't clear the error though thanks for the suggestion
Re: Errors on Run Java Application
thank John K,you help me solve the problem,but can you tell me what is this which we changed.other how can i add the class which teacher maked and we will use in our homework?
Re: Errors on Run Java Application
thank John K,you help me solve the problem,but can you tell me what is this which we changed.other how can i add the class which teacher maked and we will use in our homework?
Re: Errors on Run Java Application
I have the exact same error:
*Exception in thread "main" java.lang.NoClassDefFoundError: TextPadTest
Press any key to continue...*
It happens with any program I have, it will compile, but will not run..
Please help!! Did you find a solution to this problem!! Thanks!
*Exception in thread "main" java.lang.NoClassDefFoundError: TextPadTest
Press any key to continue...*
It happens with any program I have, it will compile, but will not run..
Please help!! Did you find a solution to this problem!! Thanks!
Re: Errors on Run Java Application
i'm on win98 se, i have the error like teresa.i try John k' solution but it doesn't work.
Please help me....
thanks
Please help me....
thanks
Re: Errors on Run Java Application
You are using the following code:
public class TextPadTest{
public static void main(String[] args){
System.out.println("TestPad Test");
}
}
====================================
Perhaps if you make this modification to the array:
public class TextPadTest{
public static void main(String args[]){
System.out.println("TestPad Test");
}
}
====================================
Did you set the environment variables correctly? Both variables PATH should include your JAVAC.EXE directory (in the JDK \bin directory, I believe). Also, delete the variable CLASSPATH or you will never get reference variables to compile.
Did you try compiling the code? Did you install the JDK on Sun? If you have J++, will that compile there? (Yes, I'm odd; I have J++ and like to switch between TextPad and J++.)
My compiler worked on either of the code segments above, though I have had problems before on compiling with reference variables. After I changed the environment variables, it was fine.
public class TextPadTest{
public static void main(String[] args){
System.out.println("TestPad Test");
}
}
====================================
Perhaps if you make this modification to the array:
public class TextPadTest{
public static void main(String args[]){
System.out.println("TestPad Test");
}
}
====================================
Did you set the environment variables correctly? Both variables PATH should include your JAVAC.EXE directory (in the JDK \bin directory, I believe). Also, delete the variable CLASSPATH or you will never get reference variables to compile.
Did you try compiling the code? Did you install the JDK on Sun? If you have J++, will that compile there? (Yes, I'm odd; I have J++ and like to switch between TextPad and J++.)
My compiler worked on either of the code segments above, though I have had problems before on compiling with reference variables. After I changed the environment variables, it was fine.
Re: Errors on Run Java Application
john, I'm somewhat of a novice. I'm on xp and cant get textpad to run my java.
How do i get to configure?
Russ
How do i get to configure?
Russ
Re: Errors on Run Java Application
ok, assuming you have the java tools set up in textpad (it's got "compile java" and "run java application" in the tools menu), and you have the java SDK installed (the default directory will be something like C:\j2sdk1.4.1), then you need to do the following things (on xp/2000 anyway).
right-click My Computer, select Properties. Click on the Advanced tab, then the Environment Variables button.
In the System variables section, there is a variable called Path. If you run a program without telling windows exactly where it is, it will look for it in all the directories in the Path. The full path to the "bin" directory of the java sdk must be in here, separated from the others by a semi-colon. Double-click on the Path variable to edit it. If the "Variable value" field is long, it might be easier to copy&paste it into textpad, edit it, then copy&paste it back. Put the path to the bin directory in here. Now it will look something like:
.;C:\WINDOWS;C:\j2sdk1.4.1\bin;....
You also want a variable called Classpath. This does not need to be deleted. This is similar to the Path, but it contains a list of the directories Java will search through to find other classes you might reference in your programs. (Java will automatically look in its own directories for normal classes such as String, so those directories don't need to be in here.) If it doesn't exist, then click the New button and put CLASSPATH as the variable name. If you ever need to reference jar files, you add the full pathname of them (plus the filename) to the end of the classpath, separating each entry by a semi-colon. However, to make things easy, the first directory Java searches should be the current directory (where the class file you're trying to run will be), which is referenced by a '.'. So the classpath will be:
.;.....
You can also give java a new classpath every time you run it with the -classpath option as John K showed above, but it's easier to put the current directory (.) permanently in the classpath.
hope this helps.
right-click My Computer, select Properties. Click on the Advanced tab, then the Environment Variables button.
In the System variables section, there is a variable called Path. If you run a program without telling windows exactly where it is, it will look for it in all the directories in the Path. The full path to the "bin" directory of the java sdk must be in here, separated from the others by a semi-colon. Double-click on the Path variable to edit it. If the "Variable value" field is long, it might be easier to copy&paste it into textpad, edit it, then copy&paste it back. Put the path to the bin directory in here. Now it will look something like:
.;C:\WINDOWS;C:\j2sdk1.4.1\bin;....
You also want a variable called Classpath. This does not need to be deleted. This is similar to the Path, but it contains a list of the directories Java will search through to find other classes you might reference in your programs. (Java will automatically look in its own directories for normal classes such as String, so those directories don't need to be in here.) If it doesn't exist, then click the New button and put CLASSPATH as the variable name. If you ever need to reference jar files, you add the full pathname of them (plus the filename) to the end of the classpath, separating each entry by a semi-colon. However, to make things easy, the first directory Java searches should be the current directory (where the class file you're trying to run will be), which is referenced by a '.'. So the classpath will be:
.;.....
You can also give java a new classpath every time you run it with the -classpath option as John K showed above, but it's easier to put the current directory (.) permanently in the classpath.
hope this helps.
Re: Errors on Run Java Application
By the way, if you change the path or classpath (or any environment variables) when textpad is open, you'll have to exit it and open it again, to enable it to read the new path/classpath/whatever.
Re: Errors on Run Java Application
I only had to enter it one time. That setting doesnt change until I go back to the preferences and change it there. Yours changes? That shouldn't happen...