PDA

View Full Version : [CLOSED] Using java applets with ext.net



ingbabic
Mar 11, 2015, 5:08 PM
Hi
Ok, here's another basic question. I have a view like this:



@{
ViewBag.Title = "TestApplet";
}

<h2>TestApplet</h2>
<object type="application/x-java-applet" width="100" height="100">
<param name="code" value="test.Main.class" />
</object>

When I open this view I get class not found exception. I have put Main.class file in subfolder test of view's folder (actually it can be anywhere, I tried a lots of locations but without success).

geoffrey.mcgill
Mar 11, 2015, 5:25 PM
Unfortunately this is not enough information for us to test the problem.

ingbabic
Mar 11, 2015, 5:39 PM
If you need a code of the applet, here it is:


package test;

import java.applet.*;
import java.awt.*;


public class Main extends Applet {
public void paint(Graphics g){
g.drawString("Hello from Java Applet.",40,20);
}
}


Code for controller is trivial as well:


public ActionResult TestApplet()
{
return View();
}


Please tell me if there's something that I can provide more

Daniil
Mar 12, 2015, 11:07 AM
Hi @ingbabic,

Please clarify do you mean that the same code is working without Ext.NET and it stops working after attaching Ext.NET to the project?

ingbabic
Mar 12, 2015, 12:06 PM
Well it didn't worked with just normal ASP.NET MVC application, so actually it doesn't have anything to do with Ext.NET.

It might be due to MVC routing, because normally you would want to put applet class in same folder where html page, consisting applet, is residing. If you do it in ASP.NET Webforms application it works that way.

However I came to this workaround. If you pack your class in jar file and provide a path of the jar in archive parameter it works. So for future reference for those who would want to do the same thing, this would be correct code:



@{
ViewBag.Title = "TestApplet";
}

<h2>TestApplet</h2>
<object type="application/x-java-applet" width="500" height="100">
<param name="code" value="test.Main.class" />
<param name="archive" value="/Applets/TestApplet.jar" />
</object>


In this example jar file should be copied in the folder Applets in the root of the project. Thanks.