I have 2 directory that look same,
ANDROID_HOME=C:\Android\sdk
ANDROID_SDK_HOME=C:\Users[user]\AppData\Local\Android\Sdk
whats the different?
can I set it in one dir?
Based on the documentation:
ANDROID_HOME
ANDROID_HOME, points to the SDK installation directory. This has been deprecated, use ANDROID_SDK_ROOT instead.
If you continue to use it, the following rules apply:
If ANDROID_HOME is defined and contains a valid SDK installation, its value is used instead of the value in ANDROID_SDK_ROOT.
If ANDROID_HOME is not defined, the value in ANDROID_SDK_ROOT is used.
If ANDROID_HOME is defined but does not exist or does not contain a valid SDK installation, the value in ANDROID_SDK_ROOT is used instead.
ANDROID_SDK_HOME
The root of the user-specific directory where all configuration and AVD content is stored
can I set it in one dir?
Ideally you shouldn't, since they serve different purpose.
Seems like the accepted answer is no longer valid. The current docs say:
ANDROID_SDK_ROOT, which also points to the SDK installation directory, is deprecated.
Source table: https://developer.android.com/studio/command-line/variables#envar
I got this message -
com.android.prefs.AndroidLocationsException: ANDROID_SDK_HOME is set to the root of your SDK: D:\AndroidStudio\SDK
ANDROID_SDK_HOME was meant to be the parent path of the preference folder expected by the Android tools.
It is now deprecated.
To set a custom preference folder location, use ANDROID_USER_HOME.
It should NOT be set to the same directory as the root of your SDK.
To set a custom SDK location, use ANDROID_HOME.
Related
I am new in java programming. I am currently using Windows. Recently I saw a video tutorial from YouTube that the instructor was setting java JDK path in system variables then created a new variable called JAVA_HOME.
Now I saw in javaTpoint tutorial that they were setting the path in user variables didn't create any JAVA_HOME variable.
So my question is what is the difference between the set path in user variables and system variables? Which one do I have to set? and what's all about JAVA_HOME?
I didn't found any proper explanation on this. Your answer would be highly appreciated.
If you set it as a user variable, it's only available to the current user. If you set it as a system variable, it's available for all users. i.e. if you log out of Windows and log in with a different user, you won't have the JDK on your system path if you set it as a user variable. If it's your personal computer and you only have one account, it doesn't matter too much. I'd recommend setting it as a system variable.
JAVA_HOME is used by Gradle and Maven build tools (and some other things) to know where the root directory of your JDK is located. It should point to the folder where the bin folder is located, ie C:\Program Files\Java\jdk-11.0.7. If you're just starting out, I wouldn't worry about it too much. It's not necessary until you start using more complex tools for development.
The difference is user variables means the variable will only be able to be used & called by the user it was created by. On the other hand, for system variables, all users can use that variable.
I would recommend setting it to the system variables for compatibility, accessibility and less chance of creating errors of variable not found.
I am trying to set up react-native (for Android) on my macOs but the app is failing to build so I am retrying it by following this link:
https://reactnative.dev/docs/environment-setup
In one of the steps, we have to add something to our $HOME/.bash_profile. I open it using vi .bash_profile and then paste the commands. Next, I am asked to 'Verify that ANDROID_HOME has been added to your path by running echo $PATH.'
When I run echo $PATH., I get this:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users//Library/Android/sdk/emulator:/Users//Library/Android/sdk/tools:/Users//Library/Android/sdk/tools/bin:/Users//Library/Android/sdk/platform-tools
I don't see the word ANDROID_HOME anywhere. Is there a problem here? Maybe with the path? Or is it being correctly verified?
I am running this in the root directory.
EDIT:
I managed to successfully setup everything and run the default AwesomeProject as well (from the root directory). However, when I try to run another project, it does not work. I see this:
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/mycompany/insta/app/android/local.properties
What's the problem? Which steps from the setup should I repeat inside this particular folder? Should I make another bash profile? I don't get what path to add in the local.properties
You can find all the environment variable documentation here: https://developer.android.com/studio/command-line/variables
According to the dev website:
If ANDROID_HOME is defined and contains a valid SDK installation, its value is used instead of the value in ANDROID_SDK_ROOT.
If ANDROID_HOME is not defined, the value in ANDROID_SDK_ROOT is used.
If ANDROID_HOME is defined but does not exist or does not contain a valid SDK
installation, the value in ANDROID_SDK_ROOT is used instead.
Try echo $ANDROID_HOME. If that returns nothing try echo $ANDROID_SDK_ROOT. One of them should return your SDK directory. If not export one of them in your bash_profile as a env variable.
Easiest solution is to do a quick install of Android Studio and selecting the option to install SDK tools. This easily sets up your environment for android. All you need to do is add the SDK tools directory to your path once the install completes.
AVD images are pedantic if you change any directories and throw SDK_ROOT errors if you change things. Most problem free solution is to either download and run the installer or download the SDK tools, run the install and specify the path directory.
Your PATH variable is being correctly modified.
Echo your ANDROID_HOME variable to see what it is. It should be /Users//Library/Android/sdk/. When you use this variable in PATH, it's automatically being expanded when you echo it. You won't see "ANDROID_HOME" in the PATH.
create local.properties file inside android folder and paste sdk.dir={ANDROID_SDK_PATH}, then restart react-native server.
This problem has to do with two things:
local.properties file
ANDROID_HOME (SDK path)
Firstly,
For the local.properties, first make sure that the file is there in your project folder/android. If the file is there open it and make sure that the sdk.dir is pointing to your android SDK directory.
and if the file is not there create it and paste this:
sdk.dir = /Users/USERNAME/Library/Android/sdk
Replace USERNAME with your username
Secondly,
make sure that the ANDROID_HOME is there in the system variables and is also pointing to your android SDK directory.
or create new system variable named ANDROID_HOME and set the value your android SDK directory path if it's not there
I am working on a java project which consumes an external jar from another project. This external jar cannot be checked-in in lib folder as it evolves continuously. So we have planned to keep the latest jar inside a folder,say 'ExtJar', under User's Home dir.
The question is how do I modify classpath to point to this jar from home dir?
So, I was looking for something like and should work for all OS platforms-
classpathentry kind="lib" path="MyHomeDir/ExtJar/myExternalJar.jar"
where MyHomeDir is a variable I defined as per the link -
- Use Eclipse classpath variable to replace absolute "sourcepath" path?
I looked into above link to add a variable but apart from this I also want this variable to point to appropriate home dir depending on OS, i.e C:\Users\\ExtJar\ for Windows OR /home//ExtJar for linux etc.
Is there any way to programatically modify value of this variable to point to home dir after evaluating which OS its being run on?
The point of a Classpath Variable is that it's value is not the same for all workspaces; each workspace defines where the variable points to.
You can still use a Classpath Variable to solve your problem, though. For example, create a variable called EXT_JAR_HOME and point it to your C:\Users\your.name\ExtJar folder. Then in the project build path, use Add Variable... to select and **Extend...* it, selecting the actual JAR file. That will result in the project's build path having an entry like EXT_JAR_HOME/ExternalJar.jar. Then each developer workspace will just need to, one time, defineEXT_JAR_HOME` and point it to the correct path. Linux users' actual location will look different than Windows users, obviously.
The point is, Classpath Variables must be defined in each workspace, that's how they're designed to work.
I used to run eclipse on my laptop. I have installed and used Secunia PSI application in order to update the apps, but once I done that I cannot run Eclipse.
This is what I have:
I set the PATH to the directory which contains javaw.exe app. The path at the PATH variable is the same as of CLASSPATH variable.
So, what are your resolutions? Done, it works now. I just simply needed to add '.;' at the end of the path link at the PATH.
Cheers
As the error message clearly states, Eclipse cannot find the entire JVM.
Add the directory that contains javaw.exe to your PATH.
Better to add JAVA_HOME as a new system variable in the same screen where you see the class path by clicking New and providing the folder location for JAVA root installation folder e.g. below:
Variable Name= JAVA_HOME
Variable Value= C:\Program Files\Java\jdk1.7.0_09
I got a native library that needs to be added to java.library.path. With JVM argument -Djava.library.path=path... I can set the path as I want.
My problem is that my other library (pentaho reporting) searches fonts based on the default java.library.path (including system directories etc) and the manual setting overrides the default path..
So : how can I add a path entry to the default java.library.path instead of overriding it (which seems to be done with -Djava.library.path)? (I wouldn't want to add the default path by hand, which wouldn't be nice for the sake of deployment)
EDIT: Sorry for missing details; I'm working with Eclipse. (The deployment is done with JNLP and there I can use nativelib under resources)
Had forgotten this issue... I was actually asking with Eclipse, sorry for not stating that originally.
And the answer seems to be too simple (at least with 3.5; probably with older versions also):
Java run configuration's Arguments : VM arguments:
-Djava.library.path="${workspace_loc:project}\lib;${env_var:PATH}"
Must not forget the quotation marks, otherwise there are problems with spaces in PATH.
If you want to add a native library without interfering with java.library.path at development time in Eclipse (to avoid including absolute paths and having to add parameters to your launch configuration), you can supply the path to the native libraries location for each Jar in the Java Build Path dialog under Native library location. Note that the native library file name has to correspond to the Jar file name. See also this detailed description.
SWT puts the necessary native DLLs into a JAR. Search for "org.eclipse.swt.win32.win32.x86_3.4.1.v3449c.jar" for an example.
The DLLs must be in the root of the JAR, the JAR must be signed and the DLL must appear with checksum in the META-INF/MANIFEST.MF for the VM to pick them up.
In Windows, like this:
-Djava.library.path="C:/MyLibPath;%PATH%"
%PATH% is your old -Djava.library.path
Can you get round this by calling System.load() programmatically to load your native library? This method (unlike System.loadLibrary()) allows you to specify an absolute path.
In UNIX systems, you can append to the LD_LIBRARY_PATH environment variable. On Windows, the JVM automatically sets the system property, java.library.path, to PATH; so if the dll is on your PATH, then you're set.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=102239 states that there is no substitution mechanics implemented in Eclipse's launcher, at least no up to release Juno.
Thus it is (almost) impossible to append or prepend another library folder to java.library.path when launching Eclipse without prior knowledge of the default setting.
I wrote almost, cause it should be possible to let Eclipse startup, dump the content of java.library.path and stop Eclipse in one command. The dump would the be parsed and then taken as the input for launching Eclipse, i.e.
#!/bin/bash
# get default value of java.library.path (somehow)
default_lib_path=$( start_dump_stop_eclipse_somehow )
# now launch Eclipse
eclipse --launcher.appendVmargs \
-vmargs \
-Djava.library.path="/my/native/lib/folder:${default_lib_path}"
On Windows: Add the path to the library to the PATH environment variable.
On Linux: Add the path to the library to the LD_LIBRARY_PATH environment variable.
On Mac: Add the path to the library to the DYLD_LIBRARY_PATH environment variable.
java.library.path is initilized with the values of the variables above on its corresponding platform.
This should work on any IDE.
You can test if the value is what you expect by calling java -XshowSettings:properties
The solution offered by Rob Elsner in one of the comments above works perfectly (OSX 10.9, Eclipse Kepler). One has to append their additional paths to that separated by ":".
You could also use ${system_property:java.library.path} – Rob Elsner Nov 22 '10 at 23:01
Window->Preferences->Java->Installed JREs.
Choose your current
JRE(JDK) and click Edit.
Fill Default VM Arguments:
-Djava.library.path=/usr/local/xuggler/lib.
The native library file name has to correspond to the Jar file name. This is very very important.
Please make sure that jar name and dll name are same.
Also,please see the post from Fabian Steeg
My download for jawin was containing different names for dll and jar.
It was jawin.jar and jawind.dll, note extra 'd' in dll file name.
I simply renamed it to jawin.dll and set it as a native library in eclipse as mentioned in post
"http://www.eclipsezone.com/eclipse/forums/t49342.html"
For some reason I couldn't get multiple folders to work (well it did for a while but as soon as I needed more dlls and added more folders, none with white spaces in the path). I then copied all needed dlls to one folder and had that as my java.library.path and it worked. I don't have an explanation - if anyone does, it would be great.
Many of the existing answers assume you want to set this for a particular project, but I needed to set it for Eclipse itself in order to support integrated authentication for the SQL Server JDBC driver.
To do this, I followed these instructions for launching Eclipse from the Java commandline instead of its normal launcher. Then I just modified that script to add my -Djava.library.path argument to the Java commandline.
On Windows, I have found that the important thing is to start Eclipse from the command line rather than from the Start Menu or a shortcut, provided that the native DLL is in a directory in your PATH. Apparently, this ensures that the proper directory is on the path.