943,779 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 5205
  • Java RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 19th, 2004
0

Java Problem with running program

Expand Post »
Hello,

This may not be the right forum for this but here goes...I am a student and am taking programming classes( JAVA ). It seems that I can compile my programs but cannot run them. My professor said my path was incorrect and gave me the correct path settings. I edited my path and made it exactly the same as the path he showed me. I still get nothing. I have not installed or uninstalled anything within months..What is funny is last year when I started this it ran and compiled fine. Then it would only run applets..now it runs nothing. The funny thing is my professor told me the way my path was nothing should have compiled or ran..After I change it..nothing runs..I tried changing it back to my old path but it still only compiles andwill not run.
I am using j2sdk1.4.1 on winxp servicepack1. The error reads Exception in thread "main" java.lang.NoClassDefFoundError:
My major problem I have a Final project and know way to test my code please help.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ZEEPLE is offline Offline
15 posts
since Aug 2004
Aug 19th, 2004
0

Re: Java Problem with running program

Tell me where your java installation is located on your hard drive.
it should be a folder something like j2sdk-xxxxx.

Also tell me if there is a folder called bin within j2sdk-xxxxx. Then tell me if there is a program called java.exe in there.

You can also install netbeans or eclipse. IDEs usually do the right thing.

Hope you can get back on your feet soon!


Ed
Reputation Points: 17
Solved Threads: 1
Junior Poster
cosi is offline Offline
153 posts
since Aug 2004
Aug 19th, 2004
0

Re: Java Problem with running program

Hello again,

Thanks for responding so quicky...

C:\j2sdk1.4.1 is where the folder is....
C:\j2sdk1.4.1\bin lies within the C:\j2sdk1.4.1 folder...

and yes...the java.exe is in the bin folder....


Reputation Points: 10
Solved Threads: 0
Newbie Poster
ZEEPLE is offline Offline
15 posts
since Aug 2004
Aug 19th, 2004
0

Re: Java Problem with running program

Go to where your program is and

try C:\j2sdk1.4.1\bin\java YourProgram
or C:\j2sdk1.4.1\jre\bin\java YourProgram

Let me know what happens and what error you get when you do this.


Ed

Quote originally posted by ZEEPLE ...
Hello again,

Thanks for responding so quicky...

C:\j2sdk1.4.1 is where the folder is....
C:\j2sdk1.4.1\bin lies within the C:\j2sdk1.4.1 folder...

and yes...the java.exe is in the bin folder....


Reputation Points: 17
Solved Threads: 1
Junior Poster
cosi is offline Offline
153 posts
since Aug 2004
Aug 19th, 2004
0

Re: Java Problem with running program

Hello Ed,

Tried your suggestion, but to no avail...Here is my path...do you see anything that could be worng with it....

C:\j2sdk1.4.1;C:\j2sdk1.4.\bin;C:\j2sdk1.4.\jre;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATITechnologies\ATI Control Panel;C:\Program Files\MicrosoftOffice\OFFICE11\Business Contact Manager\IM;C:\Program Files\MicrosoftSQL Server\80\Tools\Binn\;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ZEEPLE is offline Offline
15 posts
since Aug 2004
Aug 20th, 2004
0

Re: Java Problem with running program

Hey Zeeple,

What happens when you type what I said? type the whole path I told you and tell me what error message you see. That's the only way I can help you short of paying you a visit


Ed


Quote originally posted by ZEEPLE ...
Hello Ed,

Tried your suggestion, but to no avail...Here is my path...do you see anything that could be worng with it....

C:\j2sdk1.4.1;C:\j2sdk1.4.\bin;C:\j2sdk1.4.\jre;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATITechnologies\ATI Control Panel;C:\Program Files\MicrosoftOffice\OFFICE11\Business Contact Manager\IM;C:\Program Files\MicrosoftSQL Server\80\Tools\Binn\;
Reputation Points: 17
Solved Threads: 1
Junior Poster
cosi is offline Offline
153 posts
since Aug 2004
Aug 20th, 2004
0

Re: Java Problem with running program

I did exactly what you said and this is the error I get.....

Exception in thread "main" java.lang.NoClassDefFoundError: DrawHouse

Like I said it compiles fine...but it cannot find or will not run the class file...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ZEEPLE is offline Offline
15 posts
since Aug 2004
Aug 20th, 2004
0

Re: Java Problem with running program

Now in the directory that you ran java, can you tell me what you have there?

do a 'dir' and show me the file listing. also show me the first few lines of that java file that you're trying to run.

also, did you set JAVA_HOME="C:\j2sdk1.4.1"?

Ed
Reputation Points: 17
Solved Threads: 1
Junior Poster
cosi is offline Offline
153 posts
since Aug 2004
Aug 20th, 2004
0

Re: Java Problem with running program

Hey,

Well you lost me with the set JAVA_HOME="c:\j2sdk1.4.1"...where do you do that?
here is a pic of my file listing.

here is a snipit of code that is good I have seen it work...

public class DateTime2 extends Applet
{
private static Date now; //Date variable

//Add a main method to enable the applet to run as an application
public static void main(String[] args)
{
Frame f = new Frame(); //Create a new frame object

DateTime2 dateTime = new DateTime2(); //Create an instance of DateTime2

//Add the new instance into the frame
f.setLayout(new BorderLayout());
f.add("Center", dateTime);
f.setSize(200,255);
f.setVisible(true);

//An "anonymous" inner class used to close the window
f.addWindowListener( new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
);

dateTime.init(); //Call the applet's init method
} //End of main
Now this is not the DrawHouse code but this does not work either...Now this code functions as an applet and an application. I got this from another forum to learn how to combine the two. It does work at school but not at my home..again it compiles but does not run..
Attached Thumbnails
Click image for larger version

Name:	dir.jpg
Views:	19
Size:	154.9 KB
ID:	554  
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ZEEPLE is offline Offline
15 posts
since Aug 2004
Aug 20th, 2004
0

Re: Java Problem with running program

Please show me the first few lines of your code. It's important. If you have a package ... statement at the top, it could cause you problems if you don't put it in the right place.

So one file at a time Please show me just the first few lines of DrawHouse.


Ed
Reputation Points: 17
Solved Threads: 1
Junior Poster
cosi is offline Offline
153 posts
since Aug 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: ant build process is not working
Next Thread in Java Forum Timeline: Total New person - Help with a game....





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC