activities
latest
false
- Visão geral
- Criptografia
- Banco de Dados
- Java
- Notas de versão
- Sobre o pacote de atividades Java
- Compatibilidade do projeto
- Execução de métodos estáticos e de objeto
- Python
- WebAPI
Atividades do desenvolvedor
Última atualização 21 de abr de 2026
Para exemplificar como usar este pacote de atividades, construímos um processo de automação que mostra seus recursos de executar tanto métodos estáticos quanto de objeto, dividido em duas partes:
- For the first part, a Java library is initialized by using the Java Scope activity, then a
.jarfile containing the Java code is loaded by using Load Jar. A StaticgetArrayIntmethod is run by using the Invoke Java Method activity, returning an array of integers and storing it in aJavaObjectcustom data type. Then, by using the Convert Java Object activity, theJavaObjectis converted to a .NET array of integers - anInt32[]variable. Each value it contains is then written in the Output panel via a For Each activity. This shows how easy it is to switch between specific Java and .NET data types and then manipulate their values any way you want. - Na segunda parte, dentro do mesmo Java Scope mencionado anteriormente, uma atividade Create Java Object é usada para criar outro
JavaObjectcontendo uma classeCoordinate. Ao usar outra atividade Invoke Java Method , o métodogetCoordinateSumé executado. Os métodos do objeto podem ser chamados de maneira semelhante aos métodos estáticos, mas, em vez de usar o TargetType, desta vez a propriedade ObjetoDeDestino é usada, pois agora estamos utilizando uma variávelJavaObjectem vez de uma matriz de números inteiros. O método retorna seus valores em um terceiroJavaObjecte é convertido de volta para uma variável .NETDoubleusando outra atividade Convert Java Object . A etapa final é exibir uma Caixa de Mensagem que contém o valor na variávelDouble.
É assim que a demonstração pode ser construída:
O método estático
- Open Studio and start a new Process.
- Arraste uma atividade Java Scope para o Workflow Designer. Como nenhum caminho é especificado na propriedade Caminho da Biblioteca Java , o Scope tem como padrão usar a variável de ambiente PATH para inicializar a Biblioteca Java.
- Drag a Load Jar activity to the Designer panel.
- Assign the path to the
Objects.jarfile in the JarPath property field. - Arraste uma atividade Invoke Java Method após Load Java.
- Input the method name in the MethodName property and then fill in the TargetType field with the Java package name and the class you want to use.
Observação:
The TargetType property must be specified in the form
package.name.ClassName. For example, if we have a package calledcom.package.examplewhich contains the classUser.Profileand we want to use it, then the TargetType property should look likecom.package.example.User.Profile. - Create a
JavaObjectvariable, calledJavaObjectResultStaticMethod, to store the values returned by the Invoke Java Method activity and place it into the Result property field. - Add a Convert Java Object variable to the workflow and place the
JavaObjectResultStaticMethodvariable into the JavaObject property field. - In the TypeArgument property field, select the
System.Int32[]variable type. - Create a new
Int32[]variable, calledResultStaticMethod, and add it in the Result property field. - Next, drag a For Each activity to the Designer panel.
- Set the TypeArgument property to
Int32, and assign theResultStaticMethodvariable to the Values property field. This enables you to go through each integer of your array. - Drag a Write Line activity into the Body of the For Each activity and assign
value.ToStringinto its Text property. This helps you write all the values in theResultStaticMethodvariable in the Output panel, at runtime.
Seu fluxo de trabalho deve ficar assim:

O método de objeto
- Add a Create Java Object activity to the workflow, under the Java Scope activity used in the previous example.
- Use the name of the Java package and the
Coordinateclass to fill in the TargetType property -uipath.java.test.Coordinate. - Create a variable in the Result property field by using the Ctrl + K hotkey and name it
JavaObject. - Drag an Invoke Java Method activity to the Designer panel.
- To get the sum of the data returned by the
Coordinateclass, write thegetCoordinateSummethod into the MethodName property. - Create a variable in the Result property field by using the Ctrl + K hotkey and name it
JavaObjectResultObjectMethod. - Add the
JavaObjectvariable in the TargetObject field. - Add a Convert Java Object activity to the workflow.
- Add the
JavaObjectResultObjectMethodvariable in the JavaObject field. - In the TypeArgument property drop-down, select the
System.Doubledatatype. - Create a new
Doublevariable, calledObjectMethodResultValue, and add it to the Result property field. - Drag a Message Box to the Designer panel.
- Assign
ObjectMethodResultValue.ToStringto the Text property to display the values inside theDoublevariable. At runtime, theJavaObjectis created, containing theCoordinateclass, then thegetCoordinateSummethod is run and its results are returned in anotherJavaObject. The results are then converted to a .NETDoublevariable which is then displayed in a MessageBox.
O fluxo de trabalho final deve ficar assim:
