run java program

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Fan

run java program

Post by Fan »

Hi, I encounted the following problem when I tried to run a java program using Textpad.

I installed JDK1.3.1 first and then I set the Path and Classpath. I compiled my toy Hello.java file. Then I tried to run it but each time I had the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello

I ran the program on a Windows 2000 machine. I add the path following the instructions of JDK installation notes:
PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\JDK1.3.1\BIN
I set the classpath by adding the following line into my autoexec.bath file:

set CLASSPATH =.;C:\jdk1.3.1\bin;C:\jdk1.3.1\lib;C:\Servlet

C:\Servlet is the directory that I stored the Hello.java file.

Can any of you give me some help?

Thank you.

Fan
Thang Lê

Re: run java program

Post by Thang Lê »

Hi,

This means some class files could not be found in the TextPad-back end environment (the basic environment of your machine, not the one that you open using a DOS window or configure using a batch file).
Therefore, if you can execute your Hello.class properly in a DOS or command line window, type
echo "%CLASSPATH%"
to see what's in your "good" environment.
Then go to the "Parameter" field for the tool you used to execute java (the "crippled" environment). Include all the jar files, directories, etc from %CLASSPATH% that are missing, using the -classpath switch. You can add them one by one to see which one is actually missing. Otherwise, the safe (and quick) bet is to add them all.

For example:
C:\>echo %CLASSPATH%
.;D:\jdk1.2.2\lib\rt.jar;D:\mywork\classes;D:\mylib\lib.jar

Edit "Parameter" to add:
-classpath .;D:\jdk1.2.2\lib\rt.jar;D:\mywork\classes;D:\mylib\lib.jar

Then things should be ok.
sinaz

Re: run java program

Post by sinaz »

i am having the same problem
the same error
but the applets work but not the applications

and they don't work just from the dos prompt thought either
same error

what to do then
Ttoxcs
Posts: 1
Joined: Thu Apr 10, 2008 10:12 pm

Just do this

Post by Ttoxcs »

This is realy easy to fix. Just go to Configure Prefrences...
Go to Tools...
Run Java Aplication.
and use the following Parameters:

-classpath . $BaseName
User avatar
Nicholas Jordan
Posts: 124
Joined: Mon Dec 20, 2004 12:33 am
Location: Central Texas ISO Latin-1
Contact:

classpath does not always work as advertised

Post by Nicholas Jordan »

I have had to wrestle with this problem so much I am glass eyed about it. Right now my Run Java Application has $basename and not the -classpath switch. For awhile I had it working using a large dir listing in start/run/control_panel/system/advanced/environment variables

Later I took that out, Ant won't even use classpath because of problems parsing classpath. Trying to use packages makes it even worse.

The dot as in -classpath . usually helps things. Just keep trying things until you get something to run and work that way awhile before trying any changes. The dot means the current directory so you have to put everything there.
jeffmummey
Posts: 2
Joined: Tue May 20, 2008 8:40 pm

Post by jeffmummey »

I am having a problem setting up textpad, how, where do I find the applet jre, It is not in my prefrence area.
fliping through java
jeffmummey
Posts: 2
Joined: Tue May 20, 2008 8:40 pm

java

Post by jeffmummey »

How do I set-up notepad, not textpad, to accept java script, what evironments do I need to do this. How do I arrange the files to create an executable version of java, and how do I use the @(variables) to link to a document, I have already created with HTML.
fliping through java
User avatar
Nicholas Jordan
Posts: 124
Joined: Mon Dec 20, 2004 12:33 am
Location: Central Texas ISO Latin-1
Contact:

setup of runtime

Post by Nicholas Jordan »

C:\Program Files\Java\jdk1.5.0_12\bin\appletviewer.exe or something of that nature. Where the path I have here may be different in several places, it goes to the \bin\ of your Java installation.

Setting notepad to take js is probably something you could do with the windows shell, but that can become screwed up so I am going to leave it to your own work.

The class path thing on Win20+ has an unforseen issue of prepending a bunch of stuff to the command line - there is a no-frills servelet engine, I got it running on my machine but you really have to dig throught the EE bloat to find it.

As your code shows, you have C:\Servlet on the classpath but you are getting a no class def found error so what I really want to do is bring in Helios on this $HOME_USER_DIR stuff getting crammed because I do not have the cs skills to stay afloat in all the M$ Empire.

It is a recurrent fail, I just keep writing code and sooner or later get a fix that works for awhile and leave that alone while I write more code.

Try moving to My Documents for now, as a workaround. That is one fix I tried that worked in a hurry.
The only dumb question is one you should have asked and didn't.
Post Reply