java - 无法从 .java 类文件加载主类
问题描述
我正在使用 Python 通过使用 jupyter notebook 的名为 wot 的工具来可视化图形。它利用 Gephi,一个基于 java 的图形实用程序。我尝试运行函数以返回坐标输出文件,如下所示:
run_gephi(input_graph_file, output_coord_file, n_steps):
layout = 'fa'
import psutil
memory = int(0.5 * psutil.virtual_memory()[0] * 1e-9)
classpath = os.path.dirname(
pkg_resources.resource_filename('wot', 'commands/resources/graph_layout/GraphLayout.class')) + ':' + \
pkg_resources.resource_filename('wot', 'commands/resources/graph_layout/gephi-toolkit-0.9.2-all.jar')
subprocess.check_call(['java', '-Djava.awt.headless=true', '-Xmx{memory}g'.format(memory=memory), '-cp', classpath, \
'GraphLayout', input_graph_file, output_coord_file, layout, str(n_steps), str(os.cpu_count())])
然后它在我的 jupyter 笔记本中返回以下错误:
CalledProcessError Traceback (most recent call last)
<ipython-input-18-5fc832689b87> in <module>
----> 1 df, adata = compute_force_layout(ds)
<ipython-input-7-6cb84b9e0fa0> in compute_force_layout(ds, n_neighbors, n_comps, neighbors_diff, n_steps)
24 writer.write("{u} {v} {w:.6g}\n".format(u=i + 1, v=j + 1, w=W[i, j]))
25
---> 26 run_gephi(input_graph_file, output_coord_file, n_steps)
27 # replace numbers with cids
28 df = pd.read_table(output_coord_file, header=0, index_col='id')
<ipython-input-16-28772d0d10cc> in run_gephi(input_graph_file, output_coord_file, n_steps)
7 pkg_resources.resource_filename('wot', 'commands/resources/graph_layout/gephi-toolkit-0.9.2-all.jar')
8 subprocess.check_call(['java', '-Djava.awt.headless=true', '-Xmx{memory}g'.format(memory=memory), '-cp', classpath, \
----> 9 'GraphLayout', input_graph_file, output_coord_file, layout, str(n_steps), str(os.cpu_count())])
~/anaconda3/lib/python3.7/subprocess.py in check_call(*popenargs, **kwargs)
339 if cmd is None:
340 cmd = popenargs[0]
--> 341 raise CalledProcessError(retcode, cmd)
342 return 0
343
CalledProcessError: Command '['java', '-Djava.awt.headless=true', '-Xmx25g', '-cp', '/home/iik/.local/lib/python3.7/site-packages/wot/commands/resources/graph_layout:/home/iik/.local/lib/python3.7/site-packages/wot/commands/resources/graph_layout/gephi-toolkit-0.9.2-all.jar', 'GraphLayout', '/tmp/gephiznxedn32.net', '/tmp/coordsd64x05ww.txt', 'fa', '10000', '8']' returned non-zero exit status 1.
并在终端中找到以下消息
Error: Could not find or load main class GraphLayout
我在路径中可以找到“GraphLayout.java”和“gephi-toolkit-0.9.2-all.jar”文件,所以我真的不知道为什么加载不出来。你有什么建议吗?
- 添加 *
GraphLayout 类不包含在 Gephi 中,而是由 GraphLayout.java 定义。
解决方案
推荐阅读
- angular - 如何将现有值绑定(设置)到 Angular 中的 mat select
- maven - Maven:如何在创建 JAR 之前干净地复制目录?
- c# - 如何将此 SQL 查询转换为实体框架 lambda 表达式?
- vue.js - 为 element-ui 表设置行组件
- core-data - 可可绑定 - 特定列的排序错误
- java - 如何在类和活动之间传递字符串的 ArrayList?
- java - 如果状态栏颜色为白色,如何更改状态栏图标颜色
- c++ - 未找到 SDL2/SDL.H 文件
- ios - Firesbase身份验证iOS登录获取用户详细信息
- algorithm - 获取 2D 平面中最远的 2 个点的算法(用于家庭作业)