запуск апплета через муравья из затмения - PullRequest
5 голосов
/ 11 августа 2010

Я хотел бы запустить апплет в build.xml, например так:

<java classname="sun.applet.AppletViewer" classpath="${libraries}">
</java>

(по крайней мере, так работает в netbeans)

но я получаю сообщение об ошибке:

 [java] JVM args ignored when same JVM is used.
 [java] Could not find sun.applet.AppletViewer. Make sure you have it in your classpath
 [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:138)
 [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:764)
 [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218)
 [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132)
 [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105)
 [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
 [java]     at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [java]     at java.lang.reflect.Method.invoke(Method.java:597)
 [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
 [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
 [java]     at org.apache.tools.ant.Target.execute(Target.java:357)
 [java]     at org.apache.tools.ant.Target.performTasks(Target.java:385)
 [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
 [java]     at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
 [java]     at org.eclipse.ant.internal.launching.remote.EclipseSingleCheckExecutor.executeTargets(EclipseSingleCheckExecutor.java:30)
 [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
 [java]     at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
 [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [java]     at java.lang.reflect.Method.invoke(Method.java:597)
 [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
 [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
 [java]     at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
 [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [java]     at java.lang.reflect.Method.invoke(Method.java:597)
 [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
 [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
 [java]     at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:394)
 [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [java]     at java.lang.reflect.Method.invoke(Method.java:597)
 [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
 [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
 [java]     at org.apache.tools.ant.Target.execute(Target.java:357)
 [java]     at org.apache.tools.ant.Target.performTasks(Target.java:385)
 [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
 [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
 [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
 [java]     at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
 [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
 [java]     at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423)
 [java]     at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137)
 [java] Java Result: -1

похоже, что аргумент classpath = "..." переопределяет путь по умолчанию для eclipse-ant. к сожалению, мне действительно нужно указать дополнительный путь к классу.

Ответы [ 2 ]

8 голосов
/ 27 сентября 2010

Попробуйте использовать параметр fork.

<java classname="sun.applet.AppletViewer" classpath="${libraries}" fork="true">

Создаст новый процесс JVM и запустит ваш апплет.

1 голос
/ 11 августа 2010

Это прекрасно работает:

<project default="test">

<target name="test">
    <java classname="sun.applet.AppletViewer">
        <arg value="http://java.sun.com/applets/jdk/1.4/demo/applets/BarChart/example1.html"/>
    </java>
</target>

</project>
...