英文:
Import java package com.typesafe.config.impl.SimpleConfig using python with py4j
问题
from py4j.java_gateway import java_import
java_import(jvm, 'com.typesafe.config.impl.SimpleConfig')
java_import(jvm, 'com.typesafe.config.ConfigFactory')
java_import(jvm, 'com.typesafe.config.Config')
config = jvm.SimpleConfig()
factory = jvm.ConfigFactory
英文:
I can import all from java.*
using the jvm from JavaGateway of py4j
for example:
jvm.java.util.ArrayList
jvm.java.lang.System
random = jvm.java.util.Random()
random.nextInt(3)
or in this form:
from py4j.java_gateway import java_import
java_import(jvm,'java.util.*')
random = jvm.Random()
random.nextInt(3)
I need to import:
com.typesafe.config.impl.SimpleConfig
com.typesafe.config.ConfigFactory
com.typesafe.config.Config
But it doesn't work, I tried these ways:
jvm.com.typesafe.config.impl.SimpleConfig
jvm.java.com.typesafe.config.impl.SimpleConfig
jvm.java.typesafe.config.impl.SimpleConfig
java_import(jvm,'com.typesafe.config.*')
java_import(jvm,'com.typesafe.config.impl.*')
jvm.SimpleConfig
jvm.impl.SimpleConfig
all returns: py4j.java_gateway.JavaPackage
not py4j.java_gateway.JavaClass
as needed
答案1
得分: 1
我不清楚您想要翻译的具体内容。请提供您需要翻译的英文文本,我会帮您进行翻译。
英文:
I had to download the JAR
https://repo1.maven.org/maven2/com/typesafe/config/1.4.1/config-1.4.1.jar
then add the JAR in the ("spark.jars", jar_path)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论