AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones Java
  • Call to JavaLoad
  • Error
  • Parameters that must be passed to the Java function
  • Note
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
JavaExecuteFunction (Function)
Starts a specific static function of a given Java class.
Caution:
  • The path of the class to run must be specified by JavaLoad.
  • The Java class run must implement the following method: "static public <Return type> <Function name>".
Ejemplo
WINDEVWEBDEV - Código ServidorReportes y ConsultasWindowsJavaAjax
// Paths where the classes will be sought
// Note: Indicate folder/directory names and .jar or .zip names
// (and not just the name of .class)
sPathJavaClass is string = fExeDir()
IF JavaLoad(sPathJavaClass) THEN 
	// Java class to use
	// Note: If the class is in a subfolder of the .Jar, 
	// specify the folder. For example: "singlejar/Application"
	sJavaClass is string = "Application"
	// Function of the class
	sJavaFunction is string = "sum"
	Res is real 
	Res = JavaExecuteFunction(sJavaClass, sJavaFunction, javaDoubleReal, 1.55, 2.35)
	Info(Res)
ELSE
	Error("Incorrect Java locations", ErrorInfo())
END
// JAVA code
import java.awt.*;
import java.awt.event.*;

public class Application {
   public static double sum (double a, double b) {
       return a + b;
Sintaxis
JavaExecuteFunction(<Class name> , <Function name> , <Type of return> [, <Parameter 1> [... [, <Parameter N>]]])
<Class name>: Character string
Name of the class containing the function to run. This parameter is case sensitive: it must correspond exactly to the name specified in the class. If the class is contained in one or more packages, the full path of this class must be specified with the "/" character as separator. Example: "MyPackage/MySubPackage/MyClass".
<Function name>: Character string
Name of the Java function to run. This parameter is case sensitive: it must correspond exactly to the name specified in the class.
<Type of return>: Integer constant
Return type of the Java function among the following values:
javaBooleanType of return value: Boolean.
javaByteType of return value: Byte.
javaCharType of return value: Character.
javaDoubleRealType of return value: Double Real.
javaIntegerType of return value: Integer.
javaLongIntegerType of return value: Long Integer.
javaRealType of return value: Real.
javaShortIntegerType of return value: Short Integer.
javaStringType of return value: String.
javaStringUnicodeType of return value: Unicode String.
javaStringUTF8Type of return value: String in UTF8 format.
javaVoidType of return value: Void.
<Parameter 1>: Type corresponding to each parameter
Parameters expected by the Java function. These parameters must have the same type as the parameters expected by the Java function. Only the simple types can be used (see the Notes).
<Parameter N>: Type corresponding to each parameter
Parameters expected by the Java function. These parameters must have the same type as the parameters expected by the Java function. Only the simple types can be used (see the Notes).
Observaciones

Call to JavaLoad

  • A single call to JavaLoad must be performed in a WINDEV application or in a WEBDEV website.
    Java JavaLoad can be called as many times as necessary.
  • One of the following versions of SUN Java virtual machine is required: version 1.1, 1.2 (or sub-version), 1.3 (or sub-version), 1.4, 1.5 or 6.

Error

  • If an error occurs when running the specified class, the corresponding error message is displayed in a message box and the WINDEV application (or the WEBDEV website) is stopped.
  • Possible reasons for the problem (class not found for example):
    • wrong syntax in the class name (wrong case, class contained in a package and full path not specified, etc.)
    • class compiled with a version of SUN Java virtual machine and run with an earlier version of JRE...

Parameters that must be passed to the Java function

Only "simple" types can be used: integer, real, string, Boolean. Using another WLanguage type triggers a WLanguage error.
Therefore, you cannot call a Java function containing "byte" or "short" parameters. To call this Java function with JavaExecuteFunction, the "byte" or "short" parameters of the Java function must be changed to "int" parameters.

Note

The ".class" file is the result of the compilation of one or more files containing Java code. It does not contain the source code of the application but an intermediate format ("bytecode") intended to be interpreted by the Java virtual machine (JVM).
Componente: wd300jav.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local