-
random numbers
Here is my code. This should print out a random number, but it instead gives
me a loverly exception:
"exception in thread "main" java.lang.NoClassDefFoundError: Merge/Java"
Please help!!
import java.io.*;
import java.util.Random;
class Merge {
public static void main(String[] arg) {
Random r = new Random();
for (int i=0; i<10; i++) {
System.out.println(50+r.nextInt()%50);
}
System.out.println("Done.");
}
}
-
Re: random numbers
Try this:
java Merge
instead of this:
java Merge.java
PC2
"max" <mntf398@aol.com> wrote in message news:3aecabd6$1@news.devx.com...
>
> Here is my code. This should print out a random number, but it instead
gives
> me a loverly exception:
> "exception in thread "main" java.lang.NoClassDefFoundError: Merge/Java"
> Please help!!
>
>
>
> import java.io.*;
> import java.util.Random;
>
> class Merge {
>
> public static void main(String[] arg) {
> Random r = new Random();
> for (int i=0; i<10; i++) {
> System.out.println(50+r.nextInt()%50);
> }
> System.out.println("Done.");
> }
>
> }
-
Re: random numbers
You may also need to set the classpath on the command line. For example
if your Merge.class file is in C:\Temp\ the on the command line type: java
-classpath C:\Temp\ Merge
"max" <mntf398@aol.com> wrote:
>
>Here is my code. This should print out a random number, but it instead
gives
>me a loverly exception:
>"exception in thread "main" java.lang.NoClassDefFoundError: Merge/Java"
>Please help!!
>
>
>
>import java.io.*;
>import java.util.Random;
>
>class Merge {
>
> public static void main(String[] arg) {
> Random r = new Random();
> for (int i=0; i<10; i++) {
> System.out.println(50+r.nextInt()%50);
> }
> System.out.println("Done.");
> }
>
>}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks