Computer HardwareXbox GamesGameCubePlaystation 2PSOnePC/Windows GamesGameboy AdvanceDreamcastNintendo 64Gameboy ColorNintendo DSSony PSPXbox 360Nintendo Wii GamesPS3 Games

Neoseeker Forums » Programming and Design » General Programming » [Java]Program doesn't run

REPLY TO THIS THREAD   START NEW THREAD
| Sharemore
Options: Print   subscribe   remove   PM this thread to a friendNeoPM  
subscribe to thread Topic: [Java]Program doesn't run
Magnaillusion CM
Tu fui, ego eris
Two much Neo

wiki contributor
digimon




Magnaillusion CM's profileEmail Magnaillusion CMNeoPM Magnaillusion CM
total posts: 2304
since: Feb 2005
Oct 31, 09 at 5:39am
[Java]Program doesn't run

I've been reading Java in a Nutshell, 5th edition, to learn the basics of Java and OOP. It happens that at the first few pages, we were told to write a practice program and run it. After struggling with the javac a little, I found a software, jGRASP, that would compile and run the code for me. The catch, is, the program compiles, but it doesn't run for some reason. The code is:



And the error message is:



After it spews out that error, no more interactions are allowed to me. If anybody could help with this issue, it would be pretty much appreciated.




-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Mr Roboto
Freebies Rule
high on "N"



Mr Roboto's profileMr Roboto's neohomeNeoPM Mr Roboto
since: Jul 2004
Oct 31, 09 at 5:59am
re: [Java]Program doesn't run

Are you passing it any args? Looks like the args array is empty, and when you try to do args[0], it throws that exception. Also, what problems were you having when trying to compile at the command line?


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Magnaillusion CM
Tu fui, ego eris
Two much Neo

wiki contributor
digimon




Magnaillusion CM's profileEmail Magnaillusion CMNeoPM Magnaillusion CM
total posts: 2304
since: Feb 2005
Oct 31, 09 at 6:07am
re: [Java]Program doesn't run

I copied the code from the book as it was, also, it is the first time I built, compiled and ran a Java program, so I wouldn't know any problems or special conditions I had to fulfill. I really don't know how to pass args on jGRASP.

About the command line, it doesn't recognizes javac "as an internal or external command, program or executable". I tried Googling a solution, and I copied a couple of lines on the autoexec.bat, but to no avail.

Mag's Edit:

I tried defining the incoming argument with value of 4. It seems that the program runs well; it is the way of running the program that brings it down.


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Mr Roboto
Freebies Rule
high on "N"



Mr Roboto's profileMr Roboto's neohomeNeoPM Mr Roboto
since: Jul 2004
Oct 31, 09 at 6:40am
re: [Java]Program doesn't run

Yeah, your program was expecting input. When you run your program, you can pass it arguments. eg java Factorial 4 would put 4 in the String[] args array passed into Main. If you did java Factorial 1 3 5, your array would have three values in it.

I'm guessing you don't have your PATH variable setup properly, so the command prompt doesn't know where to look when you type javac. Instructions for that can be found here. You'd need to add the path to wherever you installed the JDK. Something like C:\JDK6\bin. You can also point directly to where you installed it if you don't want to setup your PATH. Assuming you installed the JDK at C:\JDK6, you could enter at the command prompt - > c:\JDK6\bin\javac Factorial.java


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Magnaillusion CM
Tu fui, ego eris
Two much Neo

wiki contributor
digimon




Magnaillusion CM's profileEmail Magnaillusion CMNeoPM Magnaillusion CM
total posts: 2304
since: Feb 2005
Oct 31, 09 at 6:59am
re: [Java]Program doesn't run

Perfect; thank you Mr. Roboto, now the javac command runs perfectly, compiles and runs the program without problems. As expected from the book, the code worked as it should have. Thanks again for your help on this issue.


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
tom111
(insert witty comment)
Hooked on Neo



tom111's profiletom111's neohome
total posts: 4147
since: Apr 2004
Nov 04, 09 at 11:56am
re: [Java]Program doesn't run

Cool, someone at the same level as me in Java. It's nice to know I'm not the only newbie.



-------------------
BSc Computer Science student @ Staffordshire University
quote   quick quote   edit   quick edit   del  searchposts in thread  report
[All dates in (PT) time]Threads List   « Next Newest   Next Oldest »
REPLY TO THIS THREAD   START NEW THREAD


search:
search posts by username:
Neoseeker Forums » Programming and Design » General Programming » [Java]Program doesn't run



Jump to another forum:

Powered by neoforums v0.9.8b (equilibrium)
Copyright Neo Era Media, Inc. 1999-2009

neoseeker forum community
Neoseeker.com   |   Forum Rules   |   Forum FAQ   |   Neoseeker Terms of Use   |   Supermods On Duty [ server id: ascension ··· elapsed: 0.1607508659]
Affiliated sites:   GameGrep - Football Manager Wiki - Halo Wiki - MGS Wiki - GTA Wiki - Smackdown Wiki - Zelda Wiki - PS2seeker - Xbox seeker - DEVPEN - GFXcess