last day (15 days later) » 

7:31 PM
0
A: jar file generates RuntimeException: java.lang.reflect.InvocationTargetException

shekhar sumanProbably the source of the error which I guess is that you are declaring the waterdrops.main.class in the code attribute of <applet> tag. Two things :- You don't need to include the name of the archive in the code attribute. So, code="Main.class" will suffice! try removing the Waterdrops.jar ...

 
When I remove the 'waterdrops' part from the waterdrops.main.class, I get a classNotFoundException :\
 
What is waterdrops here,another folder or that jar file???
 
It is the jar file.
 
Are you trying all this under java directory? Please try it with root directory!
If this doesn't work,there is some-kinda runtime exception caused in your Main.java source code!!!
 
I changed all of it to root after your previous comments
 
7:31 PM
Please add the source of your Main.java in the question. there is some line which is causing runtime exception,because of that also sometimes InvocationtargetException is thrown!
 
As I said, the Main function is empty:
public static void main( String[] args )
{ }
it is encapsulated in the package waterdrops, that's why I need it when I call code="waterdrops.Main.class"
 
try adding this line in psvm()---> System.out.println("Hello World!");
Again, the same ---remove that waterdrops for a while, I ain't saying to achieve things without it! But,you should climb the ladder step by step instead of just hopping through!
Also,what is the name of the class file in which psvm() is located???
 
the name is Main.class
I added System.out.println("Hello World!");
 
What??? How can name be Main.class??? It should be simply Main.Next, what happened after displaying hello world,please comment.
 
after generating the jar file, nothing happened.
should I rename Main?
or even delete it?
 
7:42 PM
No,what exactly is the name of your .java file which you have compressed as jar and under which you added hello world code.Is it Main or is it Main.class? Please patiently write.
 
the name of the class itself is Main.java
It should be the same in the .jar file
package waterdrops;

/**
*
* @author deleo
*/
public class Main
{
/**
* @param args the command line arguments
*/
public static void main( String[] args )
{
System.out.println("Hello World!");
/*WaterDrops water = new WaterDrops( );
water.start( );*/
}
}
 
good,remove it from waterdrops package. Re-deploy it to .jar under root folder and finally comment as to what you get?
 
Now I removed it from the waterdrops package but it still cannot find the Main.class without referencing waterdrops package.
Main.class doesn't work ----> classNotFOundException
waterdrops.Main.class doesn't work -----> InvocationTargetException.
 
Man---when you are deploying to jar,are you adding Main.class file or Main.java file!
 
How do I do that? I just hit Clean and Build project in netbeans
and then it generates the jar file for me
 
7:58 PM
Check the components of that jar file by extracting it! But, I guess you are correct here!!!
 
yes, it includes the classes I use, main.java is also included inside.
 
So,exact path to your Main.class in that jar file is???
 
it's just in the root.
 
are you using Netbeans ide???
 
yes
 
8:07 PM
Oh,so then Main.class will be under /build/classes/main/Main.class! Next, how are you running this applet without adding this much of path? It will damn sure throw this exception... Please cross-examine the path!
If it doesn't help, then I can't help much remotely as you're not responding positively,hiding many details!!! Wait for another answer.
 
sorry man, I get frustrated because I have been looking for an answer for a long time and everytime I fix one problem, the next one just takes its place.
 
so,I mentioned to cross-examine the path of your Main.class? Is it the same which I mentioned. Also,don't be frustated as it is the rule of nature that if you have problem,you'll have to suffer a bit unless someone helps you!
 

  last day (15 days later) »