错误:包 org.apache.commons.math.distribution 不存在。

huangapple go评论64阅读模式
英文:

error: package org.apache.commons.math.distribution does not exist

问题

以下是翻译好的部分:

我试图运行一个项目,但无法运行一个名为Utility.java的Java文件。它在以下语句中无法导入包。

import org.apache.commons.math.distribution.*;

由于我不确定应该在执行JAR文件时包含哪个路径,我尝试了两个路径命令:

root@vidhi-VirtualBox:/home/vidhi/Downloads/explorerChain/explorerchain-master# javac -cp "/Downloads/explorerChain/explorerchain-master/commons-math-1.2/commons-math-1.2.jar" Utility.java

root@vidhi-VirtualBox:/home/vidhi/Downloads/explorerChain/explorerchain-master# javac -cp "/commons-math-1.2/commons-math-1.2.jar" Utility.java

这是显示文件位置的文件夹截图

commons-math-1.2文件夹的截图

我认为文件的位置有错误。
附注:我是Java的初学者。操作系统是Ubuntu。

英文:

I was trying to run a project but unable to run a java file Utility.java. It cannot import the package in the below statement.

import org.apache.commons.math.distribution.*;

Since I have a confusion in which path should be included in cp for executing jar file I tried using the 2 paths commands

root@vidhi-VirtualBox:/home/vidhi/Downloads/explorerChain/explorerchain-master# javac -cp "/Downloads/explorerChain/explorerchain-master/commons-math-1.2/commons-math-1.2.jar" Utility.java


root@vidhi-VirtualBox:/home/vidhi/Downloads/explorerChain/explorerchain-master# javac -cp "/commons-math-1.2/commons-math-1.2.jar" Utility.java

Here is the screenshot of the folders depicting location of files

Screenshot of commons-math-1.2 folder

According to me there is an error in location of the files.
P.S. I am beginner in Java. OS is ubuntu

答案1

得分: 0

按照以下步骤编译和执行您的独立 Java 程序。

我假设您的 target-directory = /home/vidhi/Downloads/explorerChain/explorerchain-master,您将在其中执行您的代码。

将 JAR 文件 commons-math-1.2.jar 复制到位置 target-directory

命令:# cp /source-directory/commons-math-1.2.jar target-directory/

然后进入目标目录。

命令:# cd <target-directory>

接下来编译您的 Java 文件。

命令:# javac -cp commons-math-1.2.jar . Utility.java

然后运行您已编译的 Java 文件。

命令:# java Utility
英文:

Follow the below steps to compile and execute your standalone java program.

I suppose your target-directory = /home/vidhi/Downloads/explorerChain/explorerchain-master where you will execute your code.

Copy the jar file commons-math-1.2.jar to location target-directory.

Command : # cp /source-directory/commons-math-1.2.jar target-directory/

Next go to target directory.

Command : # cd <target-directory>

Next Compile your java file. :

Command : # javac -cp commons-math-1.2.jar . Utility.java

Next run your compiled java file :

Command : # java Utility

huangapple
  • 本文由 发表于 2020年9月30日 01:01:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/64124326.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定