• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ERROR in PlasmaCloud.java double displacement = StdRandom.gaussian(0, stddev);

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have

uname -a
Linux Westparkstr42 2.6.18-4-486 #1 Wed May 9 22:23:40 UTC 2007 i686 GNU/Linux


I can compile hello world like this


public class HelloWorld {

public static void main(String[] args) {
System.out.println("Hello, World");
}

}
morten@Westparkstr42:~$ javac -version
Eclipse Java Compiler v_677_R32x, 3.2.1 release, Copyright IBM Corp 2000, 2006. All rights reserved.
morten@Westparkstr42:~$ javac HelloWorld.java
morten@Westparkstr42:~$ java HelloWorld
Hello, World
morten@Westparkstr42:~$



Then I face a problem

here I found something interesting

http://www.cs.princeton.edu/introcs/23recursion/

http://www.cs.princeton.edu/introcs/23recursion/PlasmaCloud.java.html


woun't do

javac PlasmaCloud.java
----------
1. ERROR in PlasmaCloud.java (at line 35)
double displacement = StdRandom.gaussian(0, stddev);
^^^^^^^^^
StdRandom cannot be resolved
----------
2. ERROR in PlasmaCloud.java (at line 40)
StdDraw.setPenColor(color);
^^^^^^^
StdDraw cannot be resolved
----------
3. ERROR in PlasmaCloud.java (at line 41)
StdDraw.filledSquare(x, y, size);
^^^^^^^
StdDraw cannot be resolved
----------
4. WARNING in PlasmaCloud.java (at line 57)
int SIZE = Integer.parseInt(args[0]);
^^^^
The local variable SIZE is never read
----------
4 problems (3 errors, 1 warning)morten@Westparkstr42:~$



javac Factorial.java
morten@Westparkstr42:~$ java Factorial 10
3628800


I haven't tried all, Factorial works and the html code looks identical to the ascii code.

but something can be specific to my eclipse java compiler.


i did search for the first error

StdRandom had here no matches.

Best regards from a java newcomer.


Morten
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the comments of PlasmaCloud.java, it says, "Dependencies: StdDraw.java." This means that PlasmaCloud uses elements in the file StdDraw.java, and your compiler is complaining that it can't find these things. Although not listed as a dependency, StdRandom.java is also needed.

Add StdDraw.java and StdRandom.java to your directory containing PlasmaCloud.java, re-compile, and you should be okay.

(Another error in the comments is "Execution: java Plasma N". But execution should be java PlasmaCloud N, where N is some int.)
[ June 29, 2007: Message edited by: marc weber ]
 
Morten Gulbrandsen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Thanks, it still woun't compile.

http://pastebin.ca/595919

javac StdDraw.java
----------
1. ERROR in StdDraw.java (at line 111)
private static LinkedList<Character> keysTyped = new LinkedList<Character>();


morten@Westparkstr42:~/Robert_Sedgewick$ ls -l
total 36
-rw-r--r-- 1 morten morten 2472 2007-06-29 20:32 PlasmaCloud.java
-rw-r--r-- 1 morten morten 29769 2007-06-29 20:27 StdDraw.java
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note your compiler warnings: "...parameterized types are only available if source level is 5.0."

You need to change a preference in Eclipse so that it compiles with at least version 5.0 (which is the same as 1.5). This will allow the use of "generics," which appears to be what's preventing this from compiling.

See Eclipse documentation:
  • Java Compiler page
  • Java Compiler preferences
  •  
    Morten Gulbrandsen
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    1) javac warning level 2) ant makefile


    I thank you eternally for the fast reply.
    That was even as fast as IRC.

    1) javac warning level
    I have decided to only use emacs and compile as manually as possible.

    I'd like to increase the warning level.

    with gcc I would type g++ -ansi -pedantic -wall -strict_ansi or whatever.

    I now run solaris 10 developer edition and prefer bash.


    bash-3.00$ uname -a
    SunOS solaris-devx 5.11 snv_64a i86pc i386 i86pc

    man javac
    No manual entry for javac.

    I have no java manpage.

    man cc and man CC gives me immediately the appropriate manpage for C and C++ compiler.

    man java
    No manual entry for java.

    is this correct?

    Please?

    I did change my $PATH settings, after consulting with experts.

    echo $MANPATH
    /usr/dt/man:/usr/man:/usr/openwin/share/man

    echo $PATH
    /usr/bin:/usr/openwin/bin:/usr/ucb:/opt/sfw/bin


    which java
    /usr/bin/java

    which javac
    /usr/bin/javac


    java -version
    java version "1.6.0"
    Java(TM) SE Runtime Environment (build 1.6.0-b105)
    Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

    javac -version
    javac 1.6.0


    That works all fine,
    without any manpage.

    man ant
    No manual entry for ant.

    man make gives me the usual make manpage.

    That stuff with classpath I never understood, do I need to know that?


    2) ant makefile

    When I program in C C++ I use make gmake or dmake.

    Suppose I want to use the emacs for a while,
    isn't ant the appropriate make file for java?

    How do I write a simple ant makefile for a tiny helloworld program?

    Please?


    the examples from Sedgewicks homepage works fine.
    As you suggested, with the correct compiler.

    ls *.java
    PlasmaCloud.java StdDraw.java StdOut.java StdRandom.java
     
    reply
      Bookmark Topic Watch Topic
    • New Topic