![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Dec 2007
Posts: 4
Rep Power: 0
![]() |
PLEASE PLEASE help up since 1 trying to fix this simple yet stupid problem....
Good morning everyone - Just joined the site!
I really need help/advice/instuctions This is usually done via windows separate command line, i.e: c: javac myCode.java //to compile it c: java myCode somethingIwantTopassIntoTheCode //to run it with a parameter it compiles on the command line but when I try to run it I get an error: Exception in thread "main" java.lang.NoClassDefFoundError: myCode along with some other rubbish. So I cant pass arguments via the command line and cant pass arguments via netbeans. I need to do this for some uni work ASAP so If anyone knows how to fix this, or even better how to pass arguments through net bean independently It would help me soo much! As you can see I have been up all night trying to fix this, I have also searched the forums but cant seem to find a similar thread. I have also downloaded eclipse but don’t know how to pass arguments through that either: sad: I have been told by a friend to: "To specify command line arguments, right click your project node and click properties. Click the 'compile' tab to specify compiler arguments or click the 'run' tab to specify runtime arguments." but I found the tabs and places to enter the arguments and entered 4 + 1 and even though I have entered the arguments it still doesn't use the arguments. I have tried this on other code which I am sure is correct, but still doesn’t work. Do I need to do some sort of application/implementation of these arguments? If anyone knows how to pass arguments through ANY IDE PLEASE tell me how I'l download another programming environment if needs be.... thanks so much! Energizer |
|
|
|
|
|
#2 | |||
|
Hobbyist Programmer
|
Quote:
Quote:
Quote:
Here is a working example of accepting command line arguments. It uses Java 5 Enhanced For Loop to iterate the array of strings. java Syntax (Toggle Plain Text)
C:\>javac PrintArgs.java C:\>java PrintArgs arg0 arg1 arg2 yar-harg This is stuff you entered: arg0 arg1 arg2 yar-harg End of stuff you entered. C:\>
__________________
i dont know much about programming but i try to help |
|||
|
|
|
|
|
#3 | |
|
Newbie
Join Date: Dec 2007
Posts: 4
Rep Power: 0
![]() |
Re: PLEASE PLEASE help up since 1 trying to fix this simple yet stupid problem....
Quote:
This is the error I get after I copy and past your code into a new netbeans class init: deps-jar: Compiling 1 source file to C:\Users\admin\Documents\NetBeansProjects\JavaNode\build\classes javac: invalid flag: 1 Usage: javac <options> <source files> use -help for a list of possible options BUILD FAILED (total time: 0 seconds f1 help doesn't do much. here is code I wrote and tried to run: public class NewClass { public static void main (String[]args) {System.out.println("hi" + args[0]);} } and I get this error: init: deps-jar: Compiling 1 source file to C:\Users\azhari\Documents\NetBeansProjects\JavaNode\build\classes javac: invalid flag: 1 Usage: javac <options> <source files> use -help for a list of possible options BUILD FAILED (total time: 0 seconds) do you know how to pass arguments via any other enviornment e.g. j-creater, eclise etc? |
|
|
|
|
|
|
#4 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Re: PLEASE PLEASE help up since 1 trying to fix this simple yet stupid problem....
Make sure you specified arguments for your program, not the compiler.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
Here are some things to improve upon:
The Title for thread is not descriptive to your problem and contains repeated words in caps lock. Most people here will not read threads that have dummy titles because they know what's inside is not worth their effort. Being clear and descriptive in creases your chances of getting help. You Did not post code and errors originally. when doing so use the code tags(the # icon). To add java syntax highlighting put =java at the end of the opening code tag before the brace. The idea is to separate your thoughts from code and errors. It also makes the post readable. This forum has been designed to handle code posting in a manner that makes reading code easier to look at rather than it being in plain text field. When replying to some one you do not have to quote their entire message. Only quote the parts that are relevant to conversation between you and the person(s). For an example see how I quoted your post. Please read the forum rules and suggestions. If you did you would not have seen the last paragraphs As for you question: It looks like your IDE is not configured correctly. You should get it configured correctly before trying the parameters game. I know nothing of NetBeads and little of Eclipse. I know for both and any quality IDE you can pass parameters to the program. Consult the manual or search the IDE's homepage.
__________________
i dont know much about programming but i try to help |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Dec 2007
Posts: 4
Rep Power: 0
![]() |
Re: PLEASE PLEASE help up since 1 trying to fix this simple yet stupid problem....
|
|
|
|
|
|
#7 |
|
Newbie
Join Date: Dec 2007
Posts: 4
Rep Power: 0
![]() |
Re: PLEASE PLEASE help up since 1 trying to fix this simple yet stupid problem....
Thanks mrynit,
I do apologise for not setting the right format. I would have read the forum rules though I am in such as rush to get this thing finished. Your concise words have helped, and I will endeavour to follow the right code of conduct. I will try reading the IDE manual again, but it is difficult to know what to look for - search engine brings results of little use and sub topics are by the dozen. I think it may take hours of trail and error before I get this thing working. If I cant not get a result from this forum can you recommend anywhere else I should try looking? |
|
|
|
|
|
#8 |
|
Hobbyist Programmer
|
Re: PLEASE PLEASE help up since 1 trying to fix this simple yet stupid problem....
If this is for school are you required to use an IDE? If so why has not your instructor told you how to do console input?
For NetBeans http://www.google.com/search?en&q=co...ments+netbeans. The PDF looks nice. Note the search terms, google fu. In Eclipse: Click on the down black arrow next to the green circle with white arrow pointing right. Click on open run dialog. Select your application on the left. Click on the Arguments tab on the right menu systm. Enter what you want into the Program arguments.
__________________
i dont know much about programming but i try to help |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple blackjack script problem. Need help. | jokr004 | C++ | 6 | Feb 10th, 2006 12:44 PM |
| EXTREMELY simple problem | d_heyzie | C++ | 15 | Feb 3rd, 2006 12:32 AM |
| Simple Perl / MySQL Problem.. pls help! | domquemo | Perl | 0 | Jan 11th, 2006 5:08 AM |
| Problem with using DLL from simple c program. | scicatur | C | 0 | May 12th, 2005 12:19 PM |
| repaint() problem in very simple program | dotred | Java | 1 | Mar 17th, 2005 6:17 AM |