简体   繁体   English

在 ubuntu 上设置 eclipse

[英]Setting up eclipse on ubuntu

I have a small problem with Eclipse on my Ubuntu machine.我的 Ubuntu 机器上的 Eclipse 有一个小问题。 I installed JDK, set JAVA_HOME and PATH variables, all seems correct, but eclipse refuses to launch and throws an error:我安装了 JDK,设置了 JAVA_HOME 和 PATH 变量,一切似乎都正确,但是 eclipse 拒绝启动并抛出错误:

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. Java 运行时环境 (JRE) 或 Java 开发工具包 (JDK) 必须可用才能运行 Eclipse。 No Java virtual machine was found after searching the following locations: /opt/eclipse/jre/bin/java java in your current PATH搜索以下位置后未找到 Java 虚拟机:/opt/eclipse/jre/bin/java java in your current PATH

have no clue what's the problem.不知道有什么问题。 help please.请帮助。

note:笔记:

I am able to run java and javac in terminal.我能够在终端中运行 java 和 javac 。

If you get this error even though you already have JDK in your system-just follow this steps:如果您的系统中已经安装了 JDK,但仍然出现此错误 - 只需按照以下步骤操作:

1)open eclipse.ini file with text editor.
2)copy your jdk path by using -vm command (vm and your path should not be in same line)
eg:
-vm        
/usr/lib/java/jdk1.7.0_75/jre/bin/java 
3)-vm should be placed before -vmargs in eclipse.ini file.

99% works if you follow above simple steps如果您按照上述简单步骤操作,99% 会起作用

这对我有用:

ubuntu:~$ sudo apt-get install default-jre

You need to create a link at /usr/bin/java for the java binary (wherever you have placed it).您需要在 /usr/bin/java 为 java 二进制文件创建一个链接(无论您将它放在何处)。

sudo ln -s /path/to/jre*/bin/java /usr/bin/java

You probably need to set your JAVA_HOME env var something like:您可能需要将您的 JAVA_HOME 环境变量设置为:

export JAVA_HOME=/apps/java/jdk1.6.0_13

Check this answer out看看这个答案

  1. open your eclipse.ini file打开你的 eclipse.ini 文件
  2. add -vm usr/lib/jvm/jdk1.8.x_xx/jre/bin/java this must be placed before -vmarg添加 -vm usr/lib/jvm/jdk1.8.x_xx/jre/bin/java 这必须放在 -vmarg 之前

  3. save the file保存文件

  4. start your eclipse Happy Coding...开始你的日食快乐编码...

似乎eclipse在/usr/bin目录下寻找java,在这个目录中创建java命令的符号链接可以解决你的问题,至少解决我的问题

I have to run a number of jre and jdks on my machine and did not want to mess with the environment.我必须在我的机器上运行一些 jre 和 jdks 并且不想弄乱环境。 I wanted to keep 1.6 for my environment but run eclipse under 1.7.我想为我的环境保留 1.6,但在 1.7 下运行 eclipse。 I added the following line to my elcipse.ini file to specify the exact jvm to run eclipse:我将以下行添加到我的 elcipse.ini 文件中以指定运行 eclipse 的确切 jvm:

-vm
/usr/lib/jvm/jdk1.7_latest/bin/java

Obviously your path might be different.显然,您的路径可能有所不同。 Note that above jdk1.7_latest is a symlink to the specific version of the latest Java 7 jdk.请注意,上面的jdk1.7_latest是最新 Java 7 jdk 特定版本的符号链接。

Hope that helps somebody.希望能帮助某人。

This is the problem of your jdk is not setup properly for current profile.这是您的 jdk 没有为当前配置文件正确设置的问题。 Before starting eclipse in your current profile.在您当前的配置文件中启动 eclipse 之前。 Run "java -version" command on your current profile where you are running eclipse.在运行 eclipse 的当前配置文件上运行“java -version”命令。 Surely it will ask to install jdk/jre even jdk already installed but on different profile.当然,它甚至会要求安装 jdk/jre,甚至已经安装了 jdk 但在不同的配置文件上。

Hence there is two way: Solution 1. install jdk on current profile edit and add following lines vi /etc/profile export JAVA_HOME=/usr/local/jdk-1.8 export PATH=$PATH:$JAVA_HOME/bin因此有两种方法: 解决方案 1. 在当前配置文件编辑中安装 jdk 并添加以下行 vi /etc/profile export JAVA_HOME=/usr/local/jdk-1.8 export PATH=$PATH:$JAVA_HOME/bin

Solution 2: ~/.profiles export JAVA_HOME=/usr/local/jdk-1.8 export PATH=$PATH:$JAVA_HOME/bin方案二:~/.profiles export JAVA_HOME=/usr/local/jdk-1.8 export PATH=$PATH:$JAVA_HOME/bin

Solution 3: I tried and working perfectly for me.解决方案 3:我尝试过并为我完美地工作。 1. gedit /home/../eclipse/eclipse.ini 2. Add following line before -vmargs and any plugin or jar execution in eclipse.ini file 1. gedit /home/../eclipse/eclipse.ini 2. 在 -vmargs 和 eclipse.ini 文件中的任何插件或 jar 执行之前添加以下行

-startup
-vm        
/usr/local/java/jdk1.8.0_251/bin/java.exe
plugins/org.eclipse.equinox.launcher_1.5.700.v20200207-2156.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.1100.v20190907-0426
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=1.8
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx2048m
--add-modules=ALL-SYSTEM

This solution is perfectly working after explore from many stackoverflow suggestions and blogs.在从许多 stackoverflow 建议和博客中进行探索后,该解决方案非常有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM