• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

runtimeexceptionjava.lang.reflect.invocationtargetexception

 
Fernando Skackauskas
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys,

I have a javascript program that call a Java program via Applet with the following command inside the Applet:

script.code = "InJava.class";

It was necessary to make a change in the Java program, and now it creates two classes: InJava.class and InJava$1.class.

Now, when I run the program in Javascript, the program does not answer anything.

If I change the statement to: script.code = "InJava$1.class" returns the following error: runtimeexceptionjava.lang.reflect.invocationtargetexception

How must I stated in the javascript program?

Must I change something in my Java program?

The Java program is bellow:

--- Java Program_

public void sayHello() throws IOException {
java.io.FileInputStream fis = AccessController.doPrivileged(new PrivilegedAction<FileInputStream>() {
public FileInputStream run() {
try {
return new FileInputStream(parametro);
} catch (IOException e) {
String retorno_exc = e.toString();
}
return null;
}
});

Thanks,

Fernando Skackauskas.
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create a Jar file containing your class files and use that to launch the applet.

See these tutorials:
https://docs.oracle.com/javase/tutorial/deployment/jar/build.html
https://docs.oracle.com/javase/tutorial/deployment/jar/run.html
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we need a lot more detail to debug this. For example, you mention something called "script.code" but that isn't in your code. You also mention JavaScript, but you posted only Java code - what's the connection?
 
Fernando Skackauskas
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm posting the codes with more details

The problem is: when I created the javascript program at first time, there was only a InJava.class created by the Netbeans, that is invoked by the applet. But, was necessary modify the Java program. And, after the modification, the Netbeans created not only the InJava.class, but also InJava$1.class. I do not know how must include the two classes in the applet.

After this, the applet is not running anymore

---- Java script where I have the applet that invokes the program file ----

var script = document.createElement("APPLET");
script.name = "myApplet";
script.archive = "InJava.jar, NBioBSPJNI.jar";
script.code = "InJava.class"; <--------------------- HERE IS THE PROBLEM... HOW INVOKE HERE THE INJAVA$1.CLASS?
script.height = "250";
script.width = "1000";


---- Java program wrote in Netbeans ----


public class InJava extends Applet{
public void sayHello() throws IOException {
final String parametro = getParameter("parametro");
java.io.FileInputStream fis = AccessController.doPrivileged(new PrivilegedAction<FileInputStream>() {
public FileInputStream run() {
try {
return new FileInputStream(parametro);
} catch (IOException e) {
String retorno_exc = e.toString();
}
return null;
}
});
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But InJava$1.class must be the compiled version of an anonymous inner class inside your applet, whose name is InJava. I don't understand why you would want to instantiate that class.
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You already have an archive called InJava.jar - does this definitely contain both the InJava.class and InJava$1.class files?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic