Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Java

Reply
 
LinkBack Thread Tools Display Modes
Old 02-12-2007, 08:13 AM   #16 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
listen, I am kinda stuck and confused so, why dont you send me a simple "hello world" java file and class file and let me see if it works with me. my e-mail is: virus0010010@hotmail.com
thank you
virus0010010 is offline   Reply With Quote
Old 02-12-2007, 09:30 AM   #17 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Thats actualy a very simple one:
Code:
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
And you'll compile it with
Quote:
> javac filename.java
Which produces the filename.class file, then you can run it with the
Quote:
> java filename
If this produces errors like
Quote:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
Try executing it with the CLASSPATH argument ie
Quote:
> java -cp . filename
If that produces errors, please show them as they appear.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-12-2007, 12:09 PM   #18 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
ok. It worked. But it didn't give me that command in the book. What does it mean (java -cp . filename)?
I know what (java filename) means but not what you told me????
virus0010010 is offline   Reply With Quote
Old 02-12-2007, 12:32 PM   #19 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
The -cp tells it to override the CLASSPATH variabel, and use whatever you've provided instead, in this case . or current dir.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-12-2007, 04:44 PM   #20 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
As you can guess, the problem is with your CLASSPATH environmental variable. What's it's current value?
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-15-2007, 09:44 AM   #21 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
its "." like you told me to do so.
Even though the -cp command works, i still want to run my program in a normal way.
virus0010010 is offline   Reply With Quote
Old 02-15-2007, 04:42 PM   #22 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
Here's what I want you to do, I want you to give it another shot and then copy and paste everything here.

Also, I want you to run the following command:
Code:
echo %CLASSPATH%
Copy and paste the results from that too.

I still think somehow your classpath variable is getting misconfigured. I don't know how, but we should be able to figure out.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-16-2007, 02:24 AM   #23 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
you cant copy any thing from the command prompt. but when i added the echo %CLASSPATH% command, it gave me "." the same thing that i added.
And I gave it another shot but nothing happend. I still got: exeption in thread "main" java.lane.noclassdeffounderror.
virus0010010 is offline   Reply With Quote
Old 02-16-2007, 03:08 AM   #24 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
You can right-click on the command prompt, and then choose "Mark". You can then highlight the text in the window. Then, after you've highlighted everything, press Enter. You've now copied everything visible in the window.

And just to make sure (because I've seen it happen before with other people), you didn't include the quotes when you set the CLASSPATH variable, it's just the period, right?
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-16-2007, 08:17 AM   #25 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
C:\Documents and Settings\w>cd \myjava

C:\myjava>echo %CLASSPATH%
"."

C:\myjava>java Saluton
Exception in thread "main" java.lang.NoClassDefFoundError: Saluton

C:\myjava>



this is all that I get. And what do you meen by quotes? I had addded just what you told me to which is "."
virus0010010 is offline   Reply With Quote
Old 02-16-2007, 09:37 AM   #26 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
remove the quotes surrounding the . right now the CLASSPATH is pointing to a folder named "." instead of the current folder which dosn't contain any quotes.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-16-2007, 09:46 AM   #27 (permalink)
virus0010010
Recruit
 
Join Date: Feb 2007
Posts: 13
virus0010010 is on a distinguished road
OW MY GOD!! It finally worked.
thank you'll for all your help. I hope I can come back to you for any more trouble I get along the way.
virus0010010 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why doesn't this work? destin Standard C, C++ 2 03-31-2005 05:55 PM
Can't get loop to work rockybalboa Java 5 03-20-2005 04:54 PM
ASP.NET: Day / Work Week / Week / Month web calendar control with view like MS Outloo gicio MS Technologies ( ASP, VB, C#, .NET ) 0 12-10-2003 11:05 AM
San Diego Tech. work. Admin Lounge 10 02-03-2003 07:19 PM
Getting X to work in Debian w00t Linux / BSD / OS X 7 08-25-2002 02:44 PM


All times are GMT -8. The time now is 01:02 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting