-
I am finding no constructor while using javap tool for my java class...0
-
Member • Jun 19, 2012
Didn't used javap command..
but default constructor always added to class file, either it written in source code or not. did you tried for it JD java decompiler to generate source file from class file.
If you have any doubt just call super(); as first line in subclass *constructor without having any constructor in super class. see what will happen!!!!😀Are you sure? This action cannot be undone. -
Member • Jun 19, 2012
No need at all. There is always a default constructor as follows even if you dont declare yours,
It has following structure.
public class_name
{
}Are you sure? This action cannot be undone. -
Member • Jun 19, 2012
#-Link-Snipped-# I am getting the default constructor getting displayed for my java class using javap. Can you please share your java class along with javap command results?Are you sure? This action cannot be undone. -
Member • Jun 19, 2012
getting following error while using super(); in subclass constructor...😎
C:\Users\VIK\Desktop>javac *.java
B.java:6: cannot find symbol
symbol : constructor A()
location: class A
super();
^
1 errorAre you sure? This action cannot be undone. -
Member • Jun 19, 2012
I am getting no constructor using javap tool in my, class here goes the output of my class... 😎
Are you sure? This action cannot be undone. -
Member • Jun 19, 2012
your code please...Are you sure? This action cannot be undone. -
Member • Jun 19, 2012
#-Link-Snipped-# does it always happen that for each and every java program javap tool will display at least one constructor...😎Are you sure? This action cannot be undone. -
Member • Jun 20, 2012
Sure it will show you all class members using command javap -private <ClassName>Vikash Verma#-Link-Snipped-# does it always happen that for each and every java program javap tool will display at least one constructor...😎
If your code is like this one
class super1{ } public class HelloWorld extends super1{ HelloWorld (String s) { s="ABC" ; } public static void main(String[] args) { System.out.println("Hello, World"); } }
Then compile the code and use javap you will get following output
C:\Documents and Settings\<User>\My Documents\Downloads>javap -private Hell oWorld Compiled from "HelloWorld.java" public class HelloWorld extends super1{ HelloWorld(java.lang.String); public static void main(java.lang.String[]); }
For class super1.
C:\Documents and Settings\<user>\My Documents\Downloads>javap -private supe r1 Compiled from "HelloWorld.java" class super1 extends java.lang.Object{ super1(); }
Are you sure? This action cannot be undone. -
Member • Jun 21, 2012
This is what my code is displaying...😎
C:\Users\VIK\Desktop>javac B.java
C:\Users\VIK\Desktop>javap B
Compiled from "B.java"
class B extends java.lang.Object{
public static void main(java.lang.String[]);
}Are you sure? This action cannot be undone. -
Member • Jun 21, 2012
And can you Please tell what is your code? B.java?Vikash VermaThis is what my code is displaying...😎
C:\Users\VIK\Desktop>javac B.java
C:\Users\VIK\Desktop>javap B
Compiled from "B.java"
class B extends java.lang.Object{
public static void main(java.lang.String[]);
}Are you sure? This action cannot be undone. -
Member • Jun 21, 2012
I was just trying something and came to know that may be your B.java has declared constructor as "private" If you have its visibility as "private" then following command "javap B" will not show the private constructor. In order to view it you will have t explicitly run the command as "javap -private B".Are you sure? This action cannot be undone. -
Member • Jun 21, 2012
my JDK giving error while running javap B.
While "javap -private B". is working fine.
#-Link-Snipped-# , can you confirm this.Are you sure? This action cannot be undone. -
Member • Jun 21, 2012
show me the error and your B.java ?ianoopmy JDK giving error while running javap B.
While "javap -private B". is working fine.
#-Link-Snipped-# , can you confirm this.Are you sure? This action cannot be undone. -
Member • Jun 21, 2012
😲, its working, what's wrong , I was doingsookieshow me the error and your B.java ?
Here is final conclusion
With public constructor Source: public class abc{ abc(){} public static void main(String[] args) { System.out.println("Hello, World"); } } Output C:\Documents and Settings\<user>\My Documents\Downloads>javap abc Compiled from "abc.java" public class abc extends java.lang.Object{ public abc(); public static void main(java.lang.String[]); } With private constructor Source: public class abc{ private abc(){} public static void main(String[] args) { System.out.println("Hello, World"); } } Output C:\Documents and Settings\<user>\My Documents\Downloads>javap abc Compiled from "abc.java" public class abc extends java.lang.Object{ public static void main(java.lang.String[]); } With private constructor C:\Documents and Settings\<user>\My Documents\Downloads>javap -private abc Compiled from "abc.java" public class abc extends java.lang.Object{ private abc(); public static void main(java.lang.String[]); }
Are you sure? This action cannot be undone. -
Member • Jun 21, 2012
Cool...😀ianoop😲, its working, what's wrong , I was doingAre you sure? This action cannot be undone. -
Member • Jun 24, 2012
#-Link-Snipped-# you are right...😎Are you sure? This action cannot be undone.