Hot questions for Using Ubuntu in environment variables

Top Java Programmings / Ubuntu / environment variables

Question:

  1. I install ubuntu 14.04 LTS (64bit)
  2. After that Install Eclipse Luno Standard for 64bit
  3. Install Jdk and follow all the step for setting jdk using following link,

    http://www.wikihow.com/Install-Oracle-Java-JDK-on-Ubuntu-Linux

  4. Then After I enable to start my eclipse it giving me a following Error,

    VM terminated. Exit code=2

     /usr/bin/java
     -Dosgi.requiredJavaVersion=1.6
     -XX:MaxPermSize=256m
     -Xms256m
     -Xmx1024m
     -jar   /home/eheuristic/Ecclipse/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20140415- 2008.jar
     -os linux
     -ws gtk
     -arch x86_64
     -showsplash  /home/eheuristic/Ecclipse/eclipse//plugins/org.eclipse.platform_4.4.0.v20140925- 0400/splash.bmp
     -launcher /home/eheuristic/Ecclipse/eclipse/eclipse
     -name Eclipse
     --launcher.library  /home/eheuristic/Ecclipse/eclipse//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1. 200.v20140603-1326/eclipse_1605.so
     -startup /home/eheuristic/Ecclipse/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
    --launcher.appendVmargs
    -exitdata 208017
    -product org.eclipse.epp.package.java.product
    -vm /usr/bin/java
    -vmargs
    -Dosgi.requiredJavaVersion=1.6
    -XX:MaxPermSize=256m
    -Xms256m
    -Xmx1024m
    -jar  /home/eheuristic/Ecclipse/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar 
    

I so much try to solve setting Environment variable but can't do, help me one suggest to how to solve it.


Answer:

First, I strongly recommend you use the webupd8 ppa

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Then to set it

sudo update-java-alternatives -s java-8-oracle 

The advantage is ease of updates.

Question:

In my app i need send http requests via proxy. In terminal i start it by this:

java -Dhttp.proxyPort=**** -Dhttp.proxyHost=***.***.***.*** -jar app.jar 

What environment variable i should use for starting on my apps without -D options, like

java -jar app.jar

OS Linux. Java 7.

Thx!

PS already tried JAVA_OPTS, JAVA_OPTIONS, _JAVA_OPTIONS, JAVA_TOOL_OPTIONS...


Answer:

Java has two separate ways to pass parameters to programs:

  • Properties, which are typically specified in the command line arguments (as in your first example), loaded from files or manually added by code.
  • Environment Variables, which are determined by settings in your operating system.

These two concepts are separate; the former doesn't affect the latter and vice versa. As such, you cannot set a property by means of an environment variable.

Other options include loading a .properties file during runtime (assuming your proxy hasn't already been initialized at that point) or putting the full command (-D arguments and all) in a shell script for easier launching.