Click to See Complete Forum and Search --> : [RESOLVED] How do I run a NetBeans application just from the command line?
zahadumy
Jun 17th, 2006, 06:38 PM
Usually, I run a NetBeans application from the IDE, but now I need to run it from the command line using java.exe. For some reason it doesn't work and I get a java.lang.NoClassDefFoundError. I suppose you know why and you can help me. Thank you.
ComputerJy
Jun 17th, 2006, 07:10 PM
run java as exe files (http://www.download.com/Java-Runner/3000-2417_4-1987574.html?tag=lst-0-6).
This download is a very wonderful tool for all people who can compile java but can't get it to run properly
zahadumy
Jun 17th, 2006, 07:14 PM
Nice tool. :) Anyway, my problem was I was trying to run the class file and not the jar one, like I should. I forgot to mark my thread resolved. :)
Still, if you don't mind, I have an off topic question: you have in your signature my country's flag, I don't know if you know that the blue-yellow-red flag is Romania's flag. Can you please tell me what that means? Thanks.
ComputerJy
Jun 17th, 2006, 08:05 PM
Nice tool. :) Anyway, my problem was I was trying to run the class file and not the jar one, like I should. I forgot to mark my thread resolved. :)
Still, if you don't mind, I have an off topic question: you have in your signature my country's flag, I don't know if you know that the blue-yellow-red flag is Romania's flag. Can you please tell me what that means? Thanks.
This tool runs ".class" files not only .jar ones
Another thing I know what Romanian flag looks like (the embassy is next door :D ) but I got it from http://www.hostip.info/ this image makes you see your country's flag depending on your IP address.
It's actually funny, lots of people ask me if I'm from their country LOL
zahadumy
Jun 17th, 2006, 08:10 PM
Aha... nice. I didn't ask you if you're from Romania because I saw your location is Administrative Tools and not Romania. :))
System_Error
Jun 18th, 2006, 07:31 AM
Running from the command line is an essential piece of knowledge you SHOULD have. If you're too lazy to learn and rely on IDE's, then you shouldn't be a programmer. If you want to run from the command line then set your classpath to the current directory (.) and everything should go smooth.
zahadumy
Jun 18th, 2006, 08:59 AM
Ooops... someone is angry :)
I know that you run a class file using this: "java <filename>", but how am I suppose to know that if you want to run a jar file, you have to do this: "java -jar <filename>", unless I read about it? Or maybe you knew it before even Java was invented, right? I apologise if my question was too simple, but I thought that's what forums are for, right? If I have 100+ posts doesn't mean I'm not a newbie in Java, last night I used for the first time NetBeans... Thank you.
ComputerJy
Jun 18th, 2006, 09:05 AM
Ooops... someone is angry :)
I know that you run a class file using this: "java <filename>", but how am I suppose to know that if you want to run a jar file, you have to do this: "java -jar <filename>", unless I read about it? Or maybe you knew it before even Java was invented, right? I apologise if my question was too simple, but I thought that's what forums are for, right? If I have 100+ posts doesn't mean I'm not a newbie in Java, last night I used for the first time NetBeans... Thank you.
You didn't use MS DOS, did you?
Because if you did, you'd know how to use "java /?"
zahadumy
Jun 18th, 2006, 09:22 AM
I used it quite a long time. What about you? "java /?" gives me Exception in thread "main" java.lang.NoClassDefFoundErrror: /?"java" gives me what I expected. And I found this on another forum somewhere after I tried "java /?" and post the question here.
ComputerJy
Jun 18th, 2006, 09:29 AM
I used it quite a long time. What about you? "java /?" gives me Exception in thread "main" java.lang.NoClassDefFoundErrror: /?"java" gives me what I expected. And I found this on another forum somewhere after I tried "java /?" and post the question here.
Sorry, it's not "java /?"
just type "java" and it'll show you all command line options
zahadumy
Jun 18th, 2006, 09:31 AM
Yeah, but as you said, we tend to try first "<command> /?" to get the usage of a command in MS DOS. Since it didn't work, here was I asking this stupid question. Thank you for your help.
CornedBee
Jun 18th, 2006, 09:32 AM
Well, there's always the documentation that comes with the SDK. It contains (*gasp*) the documentation for the various command-line programs, too.
Oh, and SysError wasn't angry. I had the same initial thought as he did: that you found a way around the problem and didn't want to bother with actually solving the problem.
zahadumy
Jun 18th, 2006, 09:38 AM
From my first post:
Usually, I run a NetBeans application from the IDE, but now I need to run it from the command line using java.exe.
From my second one:my problem was I was trying to run the class file and not the jar one, like I should. I forgot to mark my thread resolved.
Maybe I didn't say it clear enough, but I managed to run my application from the command line using "java -jar <jarfile>". And maybe you're right and I misunderstood him, but this didn't sound very fine to me:Running from the command line is an essential piece of knowledge you SHOULD have. If you're too lazy to learn and rely on IDE's, then you shouldn't be a programmer.
ComputerJy
Jun 18th, 2006, 09:55 AM
Guys!
No need for all this tension, chill outhttp://noteme.com/vb_extension/smilies/ices_blah.gif
System_Error
Jun 18th, 2006, 02:07 PM
I wasn't angry at all. I think ALL programmers should start out with the command line and THEN move to IDE's when they've learned how to compile and run via a command line. It's a very important concept regardless of what (other) people will tell you. I feel the same way about drag and drop GUI generators. Learn to code GUI's by hand before using drag and drop generators. Getting your environment variables set right for the first time can be hard, but don't give up after 1 or 2 tries. CB and Dillenger can probably tell you, when I first started Java it took me about a week to get my command line variables right. I didn't cheap out and drop to an IDE, though. I kept with and finally got there. The standards for setting environment variables have changed since then, so all you need to do is set to current directory.
zahadumy
Jun 19th, 2006, 11:45 AM
I wasn't angry at all. I think ALL programmers should start out with the command line and THEN move to IDE's when they've learned how to compile and run via a command line. It's a very important concept regardless of what (other) people will tell you. I feel the same way about drag and drop GUI generators. Learn to code GUI's by hand before using drag and drop generators.
I don't totally agree with you. It is userful to know how to compile and run your application from command line because you can run them on any computer. That's why I learned how to do it, because I write my application in NetBeans (it's easier to develop a GUI) and I have to run them in school, where I don't have NetBeans. Another thing is sometimes I need to run once the server and several clients, and as far as I know, the IDE can only run one application (I might be wrong though).
As for the GUI develop part, what's the point to write by code a GUI, when we have NetBeans? This is concerning Java, but if you write interfaces in .Net, do you really write code to put a button on a form? I'm still mad on my teachers, friends, etc. because when we started programming in Java noone said a single word about NetBeans and we had to learn how to write interfaces by code. You may say now it's a great thing what they did, but as I understood you have more experience than I do and I might think the same way after some years...
System_Error
Jun 19th, 2006, 11:51 AM
As for the GUI develop part, what's the point to write by code a GUI, when we have NetBeans?
Do you and will you always have netbeans? You know, it's my experience that GUI builders do a terrible job of generating code. Why are you even creating this thread if you have netbeans and think it's stupid not to start off writing your own GUI's? Isn't it the same principle with running from the command line?
This is concerning Java, but if you write interfaces in .Net, do you really write code to put a button on a form?
That's totally different. .NET languages are use for RAD, java is not.
I'm still mad on my teachers, friends, etc. because when we started programming in Java noone said a single word about NetBeans and we had to learn how to write interfaces by code. You may say now it's a great thing what they did, but as I understood you have more experience than I do and I might think the same way after some years...
It is a good thing for the teacher not to start you guys off as lazy programmers.
zahadumy
Jun 19th, 2006, 12:06 PM
Do you and will you always have netbeans? You know, it's my experience that GUI builders do a terrible job of generating code. Why are you even creating this thread if you have netbeans and think it's stupid not to start off writing your own GUI's? Isn't it the same principle with running from the command line?
Probably we won't have NetBeans after a few years, or probably we will. But that's not the point. I develop the GUI using it and then use the application on a computer that might not have NetBeans installed. If let's say after 10 years we will have another GUI generator for Java, I can use that one to generate my GUI and copy+paste the code. You know that's not big deal, anyone can do it. I suppose it can be done even automatically, but it's not that important. Keep in mind the reason why I created this thread and also keep in mind it is already marked as resolved. And no, it's not the same principle. I have to know how to compile and run my application because for example if I go somewhere and I don't have NetBeans (typically at school) and I have to fix a minor thing about my program, I can edit the source code even with notepad if necessary and recompile it. One more reason is in my previous post.
System_Error
Jun 19th, 2006, 12:11 PM
And no, it's not the same principle.
Read what you said below and tell me you're not serious:
I have to know how to compile and run my application because for example if I go somewhere and I don't have NetBeans (typically at school) and I have to fix a minor thing about my program, I can edit the source code even with notepad if necessary and recompile it. One more reason is in my previous post.
So what happens when netbeans is not there to build a GUI for you? You're contridicting yourself.
The bottom line: If you can't FIRST build it by hand then don't use IDE generators.
zahadumy
Jun 19th, 2006, 12:21 PM
I meant I can fix something at the application if it's not concerning the IDE. If it is concerning the IDE, I can fix it, because I had to learn this, but I consider it totally useless. Anyway, like you said, NetBeans doesn't generate very clear code, but I can figure it out and change the code generated by it.
So what happens when netbeans is not there to build a GUI for you? I download and install it if necessary. If I don't have an internet connection, I can have a cd in my backpack with the kit (I don't, it's just an example).
The bottom line: If you can't FIRST build it by hand then don't use IDE generators.
Like I said, I had to learn how to write a GUI by hand and I know how to do it, but if I would advice someone now I would tell him to use NetBeans and not to bother with this.
Maybe I'm damn wrong about this...
ComputerJy
Jun 19th, 2006, 05:21 PM
The bottom line: If you can't FIRST build it by hand then don't use IDE generators.
:thumb: :thumb: That's totally right!
Have you tried NetBeans with Mobility-Pack?
Just change one thing and your code won't compile at all, and you can't fix it manually because it's blued (UnEditable)
zahadumy
Jun 19th, 2006, 05:34 PM
Yeah, that's what I use. To be onest, I use it just for a few days and it didn't happen to me to want to change something blued generated. But I guess you can still open it with Notepad and compile it after that, right? :)
ComputerJy
Jun 19th, 2006, 05:38 PM
Yeah, that's what I use. To be onest, I use it just for a few days and it didn't happen to me to want to change something blued generated. But I guess you can still open it with Notepad and compile it after that, right? :)
Yes
But you'll lose the GUI display on NetBeans
CornedBee
Jun 19th, 2006, 05:41 PM
Yes, but chances are you can't open the modified thing in NetBeans again.
zahadumy
Jun 19th, 2006, 05:45 PM
Umm... that sucks. You probably don't know because you write your GUI by hand, but isn't there any workaround for this?
Because if that will ever happen to me and there's no workaround for it, I'd stop using it. Serious.
System_Error
Jun 19th, 2006, 05:49 PM
I'd stop using it. Serious.
I doubt that. Your laziness has taken it's toll and closed your mind.
You probably don't know because you write your GUI by hand, but isn't there any workaround for this?
Yes. Just use the gui builder for prototyping and nothing more.
System_Error
Jun 19th, 2006, 05:51 PM
I think you should read this:
http://www.hacknot.info/hacknot/action/showEntry?eid=76
ComputerJy
Jun 19th, 2006, 05:51 PM
Umm... that sucks. You probably don't know because you write your GUI by hand, but isn't there any workaround for this?
Because if that will ever happen to me and there's no workaround for it, I'd stop using it. Serious.
I tried and looked, so stop using it.
Actually I use JBuilder for an IDE, it's not much better than NetBeans but it uses actual java classes instead of setting "Layout" to null when adding a component.
But still... I rarely use the "GUI" manager, most of the times I write my own code
CornedBee
Jun 19th, 2006, 05:52 PM
The workaround is to follow the exact conventions the tool uses to generate code.
These tools work like this: you place a control. They generate code to place the control and put it in a special section. For displaying the control, many tools just directly execute the code. (The JavaBeans architecture often allows this.) To edit a form, they parse back the code. These parsers expect the code to be in the same format as the generated code. If the parsers fail, the tools decide that the code in question is in fact not created by them and refuse to display the GUI. Thus, whatever code you write must follow the exact same conventions.
For example, it's usually safe to edit the various hard-coded numbers in the generated code.
Of course, one mistake, and you've got a big problem. I've seen it happen. I don't use GUI generators - doesn't mean I never have. I've tried them; they didn't meet my needs.
zahadumy
Jun 19th, 2006, 06:22 PM
I think you should read this:
http://www.hacknot.info/hacknot/action/showEntry?eid=76
This is the first time when you actually give me an argument, not invoking your experience. Yes, I read it and that article proves the points you guys told me earlier.
My conclusion is a GUI generator is worth using only if I'm developing a small static interface, but I can write code for that anyway, and my code will look more clear than the generated code. And I can reuse it later.
Thank you.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.