Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 15th, 2002, 06:47 PM
sema4 sema4 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Detroit
Posts: 0 sema4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to sema4
Question Problems compiling/Running Java Apps and Applets

Greetings all,

I am running Redhat Linux 7.2 and installed both the J2SDK and J2RE 1.4.0 from SUN via .rpm

I setup my PATH to accomodate my tools, javac etc but it looks like my CLASSPATH is wrong.

vi Test.java

public class Test {
public static void main( String args[] )
{
System.out.println( "Testing..." );
}
}

javac Test.java
java Test.class
Exception in thread "main" java.lang.NoClassDefFoundError; Test/class

What do I have to do?

I tried

java -cp /home/mydir/Test.class

and it spits out a list of switch options.


This is what happens when I try an applet

vi HelloWorld.java

import java.applet.*;
import java.awt.*;

public class HelloWorld class extends Applet {
public void paint(Graphics g) {
g.drawString("Hello World!", 50, 25);
}
}

vi Hello.html

<HTML>
<HEAD>
<TITLE>Hello Applet</TITLE>
</HEAD>
<BODY>
<APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>
</APPLET>
</BODY>
</HTML>

javac HelloWorld.java

HelloWorld.java:4: '{' expected
public class HelloWorld class extends Applet {

HelloWorld.java:8: '{' expected
}
3 errors


Thanks in advance for your help

Reply With Quote
  #2  
Old April 16th, 2002, 03:33 AM
oscagne oscagne is offline
Java Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 5 oscagne User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

Don't put the ".class" bit in
i.e.
java Test
OR
java /home/mydir/Test

Though you'll probably have other CLASSPATH type problems, but this'll get you past the current error. Mind you, if the compile worked it probably has access to the stuff it needs. Give it a go...

Oscagne

Reply With Quote
  #3  
Old April 17th, 2002, 12:23 AM
sema4 sema4 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Detroit
Posts: 0 sema4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to sema4
Doh!

Thanks.

Reply With Quote
  #4  
Old April 18th, 2002, 02:35 AM
aabha aabha is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: India
Posts: 7 aabha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to aabha
u have included class keyword in two places...


public class HelloWorld class extends Applet -- wrong

public class HelloWorld extends Applet -- right

--aabha

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Problems compiling/Running Java Apps and Applets


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway