|
I have tried omitting it, but still doesn't work.
|
|
|
|
|
See my edits to my previous message.
The best things in life are not things.
|
|
|
|
|
Richard MacCutchan wrote: running the command jar -tvf against the jar file that contains (or should contain) your main class
Confirms that com. is not needed, and that my main class is contained within the OmniIDE.jar file.
Richard MacCutchan wrote: Or you could execute the .jar file directly
Does not work.
|
|
|
|
|
RossouwDB wrote: Does not work.
Really not a helpful definition of a problem!
What's the output of the jar -tvf command? Also what happens when you try with the -jar option? Please show exact commands and exact output in all cases.
PS: I do not use NetBeans but Eclipse, and I know there are some bits of framework stuff that NetBeans adds to your package so it may well be that you cannot run the final package outside of the NetBeans environment. However, why that would be so is anyone's guess.
The best things in life are not things.
|
|
|
|
|
I don't know how and why, but now everything is working!!
I was typing away, and doing a clean + build like I normally do,and when I tried to run it again, it bombarded me with error messages indicating that a lot of my packages could not be found!
Stumped, I cleaned and built it a couple of times, but failed miserably when I want to run it (really odd, since it was running successfully a couple of seconds ago.)
So, I located the "broken" package, and renamed it to the package NetBeans expected. Cleaned and built it, ran it - it worked.
So i though I might give executing the application a shot, and it worked!
It's really odd though, since NetBeans should have complained right from the start, but for some reason, it didn't.
Anyway, thanks for your help.
|
|
|
|
|
|
Sorry, what?
The best things in life are not things.
|
|
|
|
|
Wait, what???? Dude, you ok? Did I say this is homework?????
|
|
|
|
|
This is no simple Java homework
Netbeans should provide a functionality to export your project in a proper way.
There is no need to build some strange stuff. That's time waisted.
regards Torsten
I never finish anyth...
|
|
|
|
|
TorstenH. wrote: This is no simple Java homework
It's NOT HOMEWORK. It's a project I am working on...
TorstenH. wrote: Netbeans should provide a functionality to export your project in a proper way.
Clearly it's not always working so well, but I would still use NetBeans.
TorstenH. wrote: There is no need to build some strange stuff
Why not??? What isn't strange in live? Clearly you are.... So am I!
TorstenH. wrote: That's time waisted
No, actually it's not! I have learned something from this entire experience, so I would not say it's time wasted!
Note:If you don't want to help people, and you want to attack them for some strange and peculiar reason, rather keep quiet! (Go read the guidelines: Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers!)
|
|
|
|
|
..That's what I said - this does not look like a simple homework-project that can be simply launched from the command line.
Why would you even want to work on the command line? All you're asking for is to run it outside of your IDE.
So I recommend to export the project in the given way and that's it. Netbeans will do what is is supposed to do - build your application.
No need to waste hours of time on fuzzy command line arguments. Better get a nice ice cream and watch Netbeans do the build
regards Torsten
I never finish anyth...
|
|
|
|
|
When we assign a subclass object to its superclass reference then the superclass reference can only access the methods that are in the superclass, it can't even the aceess its overridden methods in subclass.
if the above lines are true then how the following code can works ...
class a
{
int x;
void show()
{
System.out.println(x);
}
}
class b extends a
{
void show()
{
System.out.println("in subclass");
}
void show2()
{
System.out.println("in show2");
}
}
class Main
{
public static void main(String args[])
{
b bRef=new b();
a aRef=new b(); // why this line prints "in subclass". How a reference access the subclass?
aRef.show();
bRef.show2();
}
}
|
|
|
|
|
See the note about implicit casting in this page[^] of the Java Tutorials.
Also please put your code between <pre> tags for proper formatting.
The best things in life are not things.
|
|
|
|
|
gateway23 wrote: a aRef=new b(); // why this line prints "in subclass". How a reference access the subclass?
A reference points to an object.
Your reference points to an object of type 'b'.
|
|
|
|
|
gateway23 wrote: a aRef=new b(); // why this line prints "in subclass". How a reference access
the subclass?
It is because eventhough you have declared aRef to be of class 'a', it acutally holds an instance of class 'b' at runtime. That is what Polymorphism is all about. That's not a problem, that's the expected behavior.
|
|
|
|
|
It doesn't hold it. The heap holds it. It points to it.
|
|
|
|
|
Well, that's what I meant. Don't read the word "holds" literally
|
|
|
|
|
Shameel wrote: Don't read the word "holds" literally
That is not the point. If you must give a technical answer then make sure it is accurate and clear. Remember, many of these questions are asked by people who do not have a lot of background knowledge or experience and rely on these answers to help them in their learning. The difference between "holds" and "points to" may be crucial to a new developer.
The best things in life are not things.
|
|
|
|
|
You're right. I'll make sure I choose the right words to explain my answer. Thanks for pointing out.
|
|
|
|
|
Hello friend...
Just add this line in main()
System.out.println("aRef's type is " + aRef.getClass().toString());
and output for this line must me : aRef's type is b
when you call aRef.show() then first this call must be resolved by class of aRef's object if fuction show() not found then jvm try to resolved it from super class.
|
|
|
|
|
in java a static method can access only other static member .
But,how static main method access non-static member of other class....?
Please tell me... sir/mam
|
|
|
|
|
do not. That's bad style.
If you need static final values, put them in an Interface:
public interface IInterface {
public class Def{
public static final String
VALUE1= "Value1",
VALUE2 = "Value2";
}
}
You can then access these values like IInterface.Def.VALUE1
EDIT:
The main-class should instance a Object. Not much more to do in the main, leave the rest to the new Object:
public static void main(String[] args) {
new MyObject();
}
regards Torsten
I never finish anyth...
|
|
|
|
|
I don't like the style you've shown here for the main method. It means that your entire application is running within the scope of MyObject's contructor, which just always feels wrong to me. A constructor is there to construct an object and get it ready to do work, not to do the actual work.
I would have two classes:
public class MyApp {
public static void main(String[] args) {
MyWorker w = new MyWorker();
w.run();
}
}
public class MyWorker implements Runnable {
public void run() {
}
}
That way MyWorker can be regarded as a reusable service, and the startup code is completely separate.
|
|
|
|
|
I agree on that - luckily now it's up to you to explain all about Runnable and Thread
regards Torsten
I never finish anyth...
|
|
|
|
|
If you have a non-static member variable and the access modifier of the class allows that member to be exposed then you must have an instance of the class to access it.
|
|
|
|