Morten Gulbrandsen

Greenhorn
+ Follow
since Jun 20, 2007
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Morten Gulbrandsen

Can JavaRebel and Spring be used for visualization of concurrent threads?
Hi I am reading some of these links

http://go-parallel.com/

http://www.devx.com/go-parallel/

http://mongrel.rubyforge.org/docs/mongrel_cluster.html


and I'd like to know if the difference between
Multi threading and real parallel programming on Intel and AMD CPUs.

also Beowolf clustering and complete new mongrel clustering is interesting,
can that be done well in java, will it run well in Intel and AMD Opteron ?

Do I have to code different for SPARC and for AMD x86?
16 years ago
ok from the Java Tutorials
Lesson Interfaces and Inheritance I have this code,

public class OperateBMW760i implements OperateCar {

Direction direction;

public OperateBMW760i(Direction direction)
{
this.direction = direction;
}

// the OperateCar method signatures, with implementation --
// for example:
public int signalTurn(Direction direction, boolean signalOn) {
//code to turn BMW's LEFT turn indicator lights on


//code to turn BMW's LEFT turn indicator lights off
//code to turn BMW's RIGHT turn indicator lights on
//code to turn BMW's RIGHT turn indicator lights off

return 0;
}

Please how do I make a useful signalTurn function, It works with this method,

public void tellItLikeItIs()
{
switch (direction)
{
case LEFT: System.out.println("Left is bad.");
break;


public static void main(String[] args)
{
OperateBMW760i mortensBMW = new OperateBMW760i(Direction.LEFT);

mortensBMW.tellItLikeItIs();

OperateBMW760i mortens2BMW = new OperateBMW760i(Direction.RIGHT);

mortens2BMW.tellItLikeItIs();


}

and it runs and compiles fine

>javac -Xlint *.java

itance>java OperateBMW760i
Left is bad.
Right are better.


It would be fine if I could simulate something like 1 or 2 BMW cars driving randomely.

first turning on Light Indicator and then if getRadar tells ok
the lanes can be changed.

I have three files
public interface OperateCar {
public enum Direction {
public class OperateBMW760i implements OperateCar {
16 years ago
Hello.

from the java tutorial I have this.

http://java.sun.com/docs/books/tutorial/java/IandI/createinterface.html


C:\>type Direction.java
public enum Direction
{
LEFT, RIGHT
}


which compiles fine,

in the file OperateBMW760i.java I have tried to compile the file as published on the web

public class OperateBMW760i implements OperateCar {

// the OperateCar method signatures, with implementation --
// for example:
int signalTurn(Direction direction, boolean signalOn) {
//code to turn BMW's LEFT turn indicator lights on
//code to turn BMW's LEFT turn indicator lights off
//code to turn BMW's RIGHT turn indicator lights on
//code to turn BMW's RIGHT turn indicator lights off
}

// other members, as needed -- for example, helper classes
// not visible to clients of the interface

}


and with my own coding, like this







I end up with several error messages.

even after appending code and removing some methodes.

C:\DOKUME~1\ADMINI~1.7-0>javac -Xlint OperateCar.java

C:\DOKUME~1\ADMINI~1.7-0>javac -Xlint OperateBMW760i.java

OperateBMW760i.java:1:

OperateBMW760i is not abstract
and does not override abstract method
changeLanes(Direction,double,double) in OperateCar
public class OperateBMW760i implements OperateCar
^
OperateBMW760i.java:13: getRadarRear(double,double) in OperateBMW760i cannot imp
lement getRadarRear(double,double) in OperateCar; attempting to assign weaker ac
cess privileges; was public
int getRadarRear(double distanceToCar, double speedOfCar)
^
OperateBMW760i.java:8: getRadarFront(double,double) in OperateBMW760i cannot imp
lement getRadarFront(double,double) in OperateCar; attempting to assign weaker a
ccess privileges; was public
int getRadarFront(double distanceToCar, double speedOfCar)
^
OperateBMW760i.java:3: signalTurn(Direction,boolean) in OperateBMW760i cannot im
plement signalTurn(Direction,boolean) in OperateCar; attempting to assign weaker
access privileges; was public
int signalTurn(Direction direction, boolean signalOn)
^
4 errors


Please help, it must be something I have overlooked.

public interface OperateCar compiles fine.
16 years ago
Hello,

is it permitted to use Pencil and paper during actual SCJP exam?

Can I take my own blank paper sheets with me?
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
16 years ago
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
16 years ago
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
16 years ago
Hi,

I have seen something strange here on my debian

morten@Westparkstr42:~$ which java
/usr/bin/java
morten@Westparkstr42:~$ java -version
java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing)
morten@Westparkstr42:~$ javac -version
Eclipse Java Compiler v_677_R32x, 3.2.1 release, Copyright IBM Corp 2000, 2006. All rights reserved.


I'd like to try both netBeans, and eclipse, can they coexist ?

I have received several net Beans CDs but I remember they weren't useful for debian linux,


My question If possible I'd like to retain the eclipse ide, and also install netBeans,
will that work for debian, please?

I could not compile the helloworld program from Wikipedia

I have found some nice examples in java fro dummies, which seems to run and i could compile them,


http://www.galileocomputing.de/openbook/javainsel6/

The above link has some real nice examples which is prepared for eclipse,
I don't know how to get it up and running.

Most important, is it better to switch over to solaris 10? i think i have jcreator or jNuilder os something else installed,
Which IDE is better for the absolute beginner?

I have some experience with delphi from Borland and I very much adore the Visual Studio debugger in C++. I need something similar for java.

Please.