UpCount - recursive calamity

V4hn
Posts: 14
Joined: Tue Nov 27, 2007 12:39 pm
Contact:

UpCount - recursive calamity

Post by V4hn »

Ev'ning,

no problems solving it, but since my JavaVM stopped because of a stack overflow, when I tried to run the code, I had to port it to C...
I'm wondering, whether there is any option to increase the default stack-size in java?
Image
User avatar
lechat
Posts: 12
Joined: Wed Feb 27, 2008 10:16 am

Post by lechat »

what about 'java -X'? Then you can use 'java -Xss1024M' for 1Gb stack size...
But do you really need it?
V4hn
Posts: 14
Joined: Tue Nov 27, 2007 12:39 pm
Contact:

Post by V4hn »

lechat wrote:what about 'java -X'? Then you can use 'java -Xss1024M' for 1Gb stack size...
Ah, thanks!
I don't work with Java normally, since I don't like bytecode,
so I didn't know any parameters..
But do you really need it?
Well, not any more, since I've done that challenge,
but we're hacking to learn, aren't we?
And next time I need to run some heavy recursive java code,
I'll know how to increase the stacksize ;)
Image
Donster
Posts: 2
Joined: Tue Oct 28, 2008 8:46 am

Post by Donster »

I get the same problems with the Stackoverflow.
Then I turned the recursive function into an iterative one.
It works fine. :D
knox
Posts: 8
Joined: Wed Oct 01, 2008 7:53 pm

Post by knox »

I think donster's post is giving to much hint on solving the challenge. Maybe the post should be censored.
User avatar
adum
Posts: 392
Joined: Thu Apr 19, 2007 12:49 pm
Contact:

Post by adum »

this discussion is a little to give-away, but since the problem is really quite simple i'm not going to worry about it.
superhacker
Posts: 7
Joined: Fri Mar 06, 2009 11:10 am

Post by superhacker »

I changed the code to vb and used another method to count up ;-)

However the result i get seems to be wrong...
My result is a 5 digit number, does that sound alright?
psycore
Posts: 8
Joined: Wed Feb 18, 2009 5:40 am

Post by psycore »

lechat wrote:But do you really need it?
Uhm, since I don't even know the words recursive or iterative (should I? I'm 16), yes.
SandyThiemer
Posts: 5
Joined: Fri Mar 06, 2009 10:14 am

Post by SandyThiemer »

Hello,

i have a problem with the upcount challenge. I installed jdk 1.6.0_17 and compiled the class file without any problems but when i run the classfile i got an exception:

Exception in thread "main" java.lang.NoClassDefFoundError: upcount/class
Could not find the main class: upcount.class. Program will exit.

I really dont understand that because i changed nothing in the upcount.java file.

I hope the text above is not a spoiler...

thx in advance(?)

Sandy
DaymItzJack
Posts: 106
Joined: Thu Oct 29, 2009 9:21 pm

Post by DaymItzJack »

What are you using to run it?
SandyThiemer
Posts: 5
Joined: Fri Mar 06, 2009 10:14 am

Post by SandyThiemer »

the simple commandline tool in the jdk named java
DaymItzJack
Posts: 106
Joined: Thu Oct 29, 2009 9:21 pm

Post by DaymItzJack »

SandyThiemer wrote:the simple commandline tool in the jdk named java
How so? You might be doing something wrong.
SandyThiemer
Posts: 5
Joined: Fri Mar 06, 2009 10:14 am

Post by SandyThiemer »

the classfile from the upcount.jave is in the same directory like java and so i just type in

java upcount.class

then the error appears
megatron40
Posts: 36
Joined: Mon Aug 10, 2009 5:03 am
Location: Texas
Contact:

Post by megatron40 »

When running a Java application from the command line you don't want to append the .class extension. Just the class name. So in your case it would be something like

Code: Select all

java upcount
Last edited by megatron40 on Thu Dec 24, 2009 7:18 pm, edited 1 time in total.
"The man who doesn't read... has no advantage over the man who can't read..." - Mark Twain
SandyThiemer
Posts: 5
Joined: Fri Mar 06, 2009 10:14 am

Post by SandyThiemer »

oh youre right! Thx! What a dumb failure :-D
Post Reply