See Furst

Greenhorn
+ Follow
since Aug 04, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by See Furst

Unnsse Khan wrote:Hello there,

Having trouble running tomcat on Ubuntu Linux 7.0.4.

I installed tomcat under:

/home/untz/DevTools/Java/tomcat/apache-tomcat-5.5.25

Created the CATALINA_HOME system environmental variable inside my .profile directory.

When I try to run TOMCAT, this is what I get:



This file (catalina.sh) is obviously located in the right directory...

When I try to run this file, this is what I get:



My CLASSPATH is set as:



What am I possibly doing wrong?

Happy programming,

Unnsse



Hehe I get this:

something in the path is wonky.. but the server seems to start fine.
12 years ago

Rob Spoor wrote:You can import one; that already decreases your problem by half.



And how would I import the other? I guess subclass it.. or abstract it?

Of course the obvious answer is use better names but.. unfortunately .. I'm stuck..

I'm taking the subclass route, now that you mention it. It's.. sloppy.. I know.. but... Java could use a typedef kind of keyword. It screams for it. Especially with all these frameworks using common name like "Node", "Item", "Session" jcr is completely built like that.. and that's a Java spec...

Didn't look around too much did they..

13 years ago
Ok.. So I got two classes...and they got the same (ok similar) name.

com.thing.mine.package.Item
com.otherthing.mine.package.Item

I need both. Do I really have to explicitly call both?




Is there like a typedef call like in C++ that can help with this?

like:

13 years ago
Ok I came across an interesting dilema and was wondering if anyone could answer it.

This is probably not good practice and you would never do it.. but for an intellectual exercize

Lets say I have the following class in a package com.thing.mine:



Now how would a class outside the com.thing.mine package access the members of the static inner class?

Here are some attempts which came up with compiler errors



access error

and



access error

also this one for kicks




Also gave, to my surprise, an access error istead of a class not found error... According to convention com.thing.mine.StaticInner.SimpleConstants should be in com/thing/mine/StaticInner/SimpleConstats.java.. but I get an access error... That would certainly have my head banging against a wall for hours. Is that even to spec?

Anyway let me know what other stuff you all may find.

Thanks,
See.

13 years ago

Ankit Garg wrote:The wrong options G and H have been reported many times before like here and here. Option F won't work as class MusicPlayer is in a package, so you have to use the fully qualified name of the class i.e. player.MusicPlayer and for that the classpath must be set to the parent directory of player directory...



Thanks Ankit. I appreciate that. I just have a question. How do you know without looking at the code that MusicPlayer is in a package? In other words since they don't show you the code, what is it about the question that leads you to that conclusion? Who's to say that the developer didn't put the project in a player directory and MusicPlayer is the main class? Should one assume such things? The question doesn't really shed light on what the developer's intentions were.


Ok here's the question:

Which are true about java regex



One answer is:

The '.' metacharacter searches for alphabetic characters



The Learn Key Master Exam maintains that this answer is false because the '.' metacharacter searches for everything that is not a newline.

I would maintain that this true for exactly that reason! Alpha numerics are a subset of the group that this metacharacter searches for. It searches for anything that is not a new line.

So if I'm searching for A and B is a subset of A then it's implied that I am searching for B if B is a member of A.. And if any of you study boolean algebra you would know that if B is included in set A then B -> A.


Here is some proof: Ok so if this statement above is false it means that the statement : "The '.' metacharacter does not search for alphabetic characters" is true
Let's test that out.



Is the code we're gong to use. Now, we have to assume that if something is found by a regular expression pattern, then that pattern is indeed looking for it.

Proof:

Let's take the pattern \d*. This example is in one of the self tests in Sierra and Bates' book, actually. If we are given the string 'abdrf1232' , what would the result be? We know that the expression is looking for 0 or more digits. So, it's looking for digits.

Let's modify the code above to do this.



Here is the output:

index 0:
index 1:
index 2:
index 3:
index 4:
index 5: 1232
index 9:
we find that start() is setting the index each time while group() is giving us what we are looking for.. So we know that the ouput of group() is what the expression is looking for.

So then let's run the first code with the '.' metacharacter.

Here is the output:

index 0: O
index 1: C
index 2: J
index 3: P

This means that '.' absolutely searches for alphabetic characters.

I saw this question on one of the practice tests in the Learn Key Master Exam and I canceled my appointment. I'm not going to get certified by people who think that this is good code or even correct in any way.


All of you: You want to prove that you can develop in java.. Get a source forge or github account and write some java code. Not a OCJP certificate.

You'll be a better programmer for it too.

here is the question # 68:


Given that the MusicPlayer project is on a UNIX system and consists of the following files:
/mp/player/MusicPlayer.java
/mp/classes/player/MusicPlayer.class
/mp/jars/mp.jar

Inside mp.jar the structure is:

player/MusicPlayer.java
player/MusicPlayer.class

you are currently in directory
/mp

and CLASSPATH is set to /mp/jars

What command(s) can you use to invoke the player.MusicPlayer class (Choose all the apply) ?




Two of the answers included:

G. java -cp jars/cp.jar MusicPlayer
H. java -cp jars/cp.jar player.MusicPlayer

H is listed as a correct answer when there is no such file as cp.jar. Believe me, UNIX is never that forgiving.

There's another answer that was wrong I'm curious about.

F. java -cp /mp/classes/player MusicPlayer

It said this wouldn't work. Why? That's the absolute classpath and the class right under there. Is this another mistake?

Also I'm very curious as to how Oracle would deal with a situation like this. Because half of the Oracle exam is not to be tricked by the Oracle exam. There is no way to guarantee that H. was not a way to trick you. So Many test takers who deserve to get this question right are going to get this wrong because Oracle misspelled something. So how do they handle that? Regrade? free vouchers?


Anyone know where I can notify Learn Key? I wrote to McGraw Hill but they don't run Learn Key do they?

Rikesh Desai wrote:

Rikesh Desai wrote: Vehicle a = new Car(); //Line 11
Colorable i = (Colorable) a; //Line12

Line 11 is creating a reference of Vehicle and an object of Car.
Why Line 12 is not throwing a ClassCastException - as the reference of the object is of type Vehicle which is NOT implementing the interface?




I am still confused!



They are not talking about that.. That's perfectly legal and doesn't throw exception because a is an instance of Car polymorphed as a Vehicle so you can downcast it to a Colorable because Car implements Colorable.

However b is an instance of Vehicle which doesn't implement Colorable and so you can't cast it as such.

Wouter Oet wrote:

mohitkumar gupta wrote:
UPCAST



It allows to call methods of Animal not defined in Dog and
Methods overriden by Dog.

No it still calls the methods in Dog and not in Animal (except for static methods).



I think that's what he meant.. If Animal has a fart() then a new Dog() can fart(), but it's defined in Animal, not Dog. However if both Dog and Animal define fart() the implementation in Dog is executed..

Still if you do:



and Dog implements howl();

a.howl() will crash

I just finished posting on what's a definition vs. implementation..Oracle and I disagree... What are people's takes? What does it mean to "define" a method vs. "implement" it?

See Furst wrote:

Bert Bates wrote:Well the Calendar methods you mentioned are in the book. And as far as the others go, when mock exam writers make their mocks they often include methods that they're not sure are in the real exam, just to be safe. The end result is that a lot of mock exams test you on topics that aren't in the actual exam.

I think that if you ask on this forum other ranchers can tell you which mocks most closely follow the real exam.

hth,

Bert




Enum's ordinal() function is not explained or even mentioned anywhere AFAIK, however it's on the Learn Key's Master Exam practice suite which I believe are to be exam questions, no? It's funny; I read this post and then just five minutes later a question with this function came up.

I also noticed that some of the practice tests have mistakes. I emailed a few to McGraw Hill for you to review..

I'll just mention them briefly: one piece of code in an answer for the self test has getBidValue instead of getValue so when you compile, it fails, the answer is not compilation fails

Another has the answer printed wrong.

Your book is helpful indeed but, I don't trust it as a study guide.. Every time I get an answer wrong I have to think about whether it's really me getting it wrong or the book just being wrong..

Most of the time, of course, it's me, however, keep in mind, there are mistakes in this book.



While we're on the subject. Who said that run() is defined in Thread.. Thread IMPLEMENTS run() but run() is defined in the Runnable interface..

<rant>

This is why I hate these damn standardized tests.. they trick you with some stupid switch of the definition of terms...

This comes in regard to a question... Which methods are defined in class Thread?

A definition in my mind is different from an implementation.. An implemention is HOW SOMETHING IS DONE... Thread defined how it does run(). However the signature of run() is how I would deem it defined. This is defined in interface Runnable..



stupid tests and their stupid terms.. I'm going to fail because Oracle and I don't agree on terms..

@#$@# Oracle and their horse!

</rant>

Bert Bates wrote:Well the Calendar methods you mentioned are in the book. And as far as the others go, when mock exam writers make their mocks they often include methods that they're not sure are in the real exam, just to be safe. The end result is that a lot of mock exams test you on topics that aren't in the actual exam.

I think that if you ask on this forum other ranchers can tell you which mocks most closely follow the real exam.

hth,

Bert




Enum's ordinal() function is not explained or even mentioned anywhere AFAIK, however it's on the Learn Key's Master Exam practice suite which I believe are to be exam questions, no? It's funny; I read this post and then just five minutes later a question with this function came up.

I also noticed that some of the practice tests have mistakes. I emailed a few to McGraw Hill for you to review..

I'll just mention them briefly: one piece of code in an answer for the self test has getBidValue instead of getValue so when you compile, it fails, the answer is not compilation fails

Another has the answer printed wrong.

Your book is helpful indeed but, I don't trust it as a study guide.. Every time I get an answer wrong I have to think about whether it's really me getting it wrong or the book just being wrong..

Most of the time, of course, it's me, however, keep in mind, there are mistakes in this book.
ok.. given the following:



The question is

Given that CharSequence is an interface implemented by String and StringBuilder which of the following can be inserted at insert here to compile and run without error



One of the answers is:

s.toString();

According the API the signature of toString() is

public String toString()

which means that object returned by such a call is a String object which extends CharSequence and thus meets the requirements of <S extends CharSequence>

However this is the wrong answer..

Why? S has to extend CharSequence however if I declare a type S that extends CharSequence... my input can be a StringBuilder, but my return type can be a String ... they both fit the requirement.. or it is that S has to be the same type S for all s thus the class of the input and the output in this case must be an S??? Does that follow polymorphism rules? can s be a subtype of S as long as IS-A S is true?



I dunno.. loosing hope of passing this test.

David Newton wrote:

See Furst wrote:If you have a solid grounding in OOD


Both Scala and Jython are OO, and moreso than Java. Scala's syntax and type system are more complex than Java--moving to Scala is *substantially* more difficult for a C/C++ programmer. *Substantially*. That's why Java's syntax is what it is--to make moving from C++ *easier*.

[...] more functional languages including C


You must mean procedural, because C is not a functional language by any definition I'm aware of.

You forget that perl was once the glue of the internet


No, I actually don't.

Most people who dis Perl are usually people who never used it or don't really understand it.


Lol.

I believe that was mostly due to floundering when it came to perl 6...


No, Perl 6's issues weren't why people (largely) moved to other solutions--it was because people liked the other solutions better than Perl for this purpose.

I have, you just didn't like how it tasted and to that I say "you and your horse!"


No, I just think you're wrong. Rants have to have content. Mostly you said "Java is bloated" and "Perl is cheap". Not part of a discussion about languages, and doesn't really bring anything interesting to the table.



And again that's your opinion based on what you think it was I was trying to do... so we'll have to agree to disagree on that.

As to why perl 6 died I'm not so sure that the tools we're inadequate. I just think there were more resources available. What I mean by that is, if you got stuck or needed expert advice, you could pay for it and get plenty of it from the guys who built the technology. Perl unfortunately lacks this. I find Java's syntax very strict and time consuming build with and to get things done with while I find perl's and Scala's syntax not so. . and we can go on for days about the ROI on that.

However in the end I must side with Mr Peak, Java is better because my workplace is using it and I don't poop where I eat.



13 years ago
I run the following code on Ubuntu Linux with the following JVM:

java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.1) (6b18-1.8.1-0ubuntu1~9.10.1)
OpenJDK Client VM (build 16.0-b13, mixed mode, sharing)


here's the code:


Here's the output:

3,678.9856

What happened to my '7'? I said 7. Did I not say .9857 not 6.... who said 6? the JVM said 6. Why?


Ah maybe I should use printf... duh...

Nope that didn't work either....
13 years ago

Java isn't particularly hard to learn, and relative to Perl, I'd think it debatable which is easier, depending on the problem space.


If you have a solid grounding in OOD, it makes it easier. Many people I know who grew up with more functional languages including C peruse Java, barf and leave. Never to touch the language again, and try instead to see if Scala or Jython or something like that can get done what they need.


Ew. Perl is *far* from perfect for a web back end, and as a language, leaves much to be desired. It has its place, but IMO that isn't it. Now, if you want to discuss things like HOP, we can begin having a reasonable discussion about Perl--



You forget that perl was once the glue of the internet, complete with cold fusion and jsp style markup language like HTML::Mason and TemplateToolkit. On a server with mod_perl or fastCGI you can fly. I've seen it, done it and usually for far far far less money than Java requries (Java = bloatware = more hardware = more money is the logic I'm using here) Most people who dis Perl are usually people who never used it or don't really understand it. Yes it lost popularity, but I believe that was mostly due to floundering when it came to perl 6... development stagnated, and because there was no Sun or Oracle to back it up.. it is the real open source about as open source as GNU tools itself.


Depends on your needs, doesn't it? A lot of stuff I've worked on would be really difficult in other environments. (*Really* difficult.) Now that JVM languages are catching up speed-wise I can use way better languages, but the environment itself... tough to beat.



If you have the server power to run it yes. I work for a Java house and well.. we have at least 2 datacenters running some very large clusters in order to get the site to do what it needs with Java. I used to believe that Perl didn't have as many capabilities that other technologies did, however the more I looked, the more I realized that I was wrong. Perl's tech isn't going to jump out at you and say "hey I'm here" like other techs. Its because other techs like Java depend on profit, their goal is profit. Oracle bought Java for profit, their goal is profit... Perl is just about the tech... it's goal is to make it run and run well. Sometimes it succeeds and sometimes it fails.

otherwise you haven't brought much to the table here.



I have, you just didn't like how it tasted and to that I say "you and your horse!"



13 years ago