A Java and Maven noob here:
Using OSX 10.8
And Installed Maven with HomeBrew
1- If I say which mvn I will get this: /usr/local/bin/mvn
2- If I say echo $MAVEN_HOME I will get nothing back.
3- If I go to my Maven Installation on EClipse it will look like this:
4- If I go to Maven settings in IntelliJ, it will look like this: So far I have been able to run Maven goals with IntelliJ.
Ok That's all I have. Can you please take a look and see what are the inconsistencies I am having and what things to fix to set this correctly everywhere?
Under Mac OS X you should setup your environment variables in /etc/launchd.conf. Variables loaded by launchd are available in your shell as well as in GUI applications like Intellij IDEA.
Intellij IDEA will use M2_HOME to find the Maven installation. Edit or create /etc/launchd.conf:
setenv M2_HOME /usr/share/maven
Unfortunately to see the effect, you have to reboot your machine. Another shortcoming is, that you cannot use spaces in the file. This means, you cannot set MAVEN_OPTS to more than one value.
Related
I've configured an environment variable in ~/.bashrc as well as ~/.profile.
When I run my application via IDEA's Gradle Configuration, my environment variable is apparently not available. E.g. I am referencing this variable within application.yml, but the default value is being used instead. Running Gradle from the command line correctly picks up my variable.
How can I configure IDEA to load this environment variable in a global way, so I don't have to manually add it to every project where I need it (~20 projects)?
Note: running on Manjaro Linux v18.
It turns out IDEA will pick up environment variables if you define them either in e.g. /etc/environment or /etc/profileor if you use ZSH,~/.zshrc`.
After setting variables, you to execute source ~/.bashrc and source profile to update and execute the file contents.
# josh-m I ran into the same problem in my IntelliJ IDEA setup with Maven.
In the end, I continued to keep the settings on each project, as there were not many, but when I studied the problem I found this IntelliJ support link:
https://youtrack.jetbrains.com/issue/IDEA-141832
At least at that time, this functionality was not available in IntelliJ directly, although the following plugin, mentioned in the comments of the support article, could perhaps be of some help:
https://plugins.jetbrains.com/plugin/7861-envfile/
launchctl setenv HADOOP_VERSION 3.1.1.7.2.8.0-SNAPSHOT
Execute in this way to set your environment variables in MacOS for them to be used by other applications.
After that restart your IDE.
I downloaded lombok.jar (lombok-1.16.14.jar) put it into my Downloads. Then I clicked on this jar, the execution correctly identifies the Eclipse instances on my MacOS and then I selected the instance I want. Lombok is also specified in the pom.xml
org.projectlombok
lombok
1.16.14
provided
In eclipse.ini I got the addition:
-javaagent:../Eclipse/lombok.jar
lombok.jar was added to the same directory as eclise.ini
/Applications/Eclipse.app/Contents/Eclipse
I am still getting setter/getter errors in Eclipse Problems despite that my mvn build works fine.
The code for a User:
#Entity
#Getter
#Setter
#NoArgsConstructor
#AllArgsConstructor
#EntityListeners(UserListener.class)
public class User implements Serializable, UserDetails {
...
The error:
The method getRole() is undefined for the type User
Since you have already added the .jar to your lib folder, then go to the lib
and execute java -jar lombok-1.16.4.jar, you'll see a wizard, specify the location of your eclipse.ini, after you are done with this your eclipse.ini file should look like this:
-vmargs
...
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar
For me this just worked fine but I found in other answers that:
You should not just "restart" Eclipse, go to File -> Exit and then open it again. taken from here
Don't forget to do a mvn clean just to make sure that you recompiled your classes. taken from here
After all this you should also right-click on your project, then Maven -> Update Project taken from here
There is a manual way to install lombok under eclipse, I do not checked it, but it maybe helps you -
copy lombok.jar to where your eclipse folder where is the eclipse.ini
open eclipse.ini,put at end the below two lines below and save it
-Xbootclasspath/a:lombok.jar
-javaagent:lombok.jar
restart eclipse.
I had the problem, that the link, which I used to start eclipse, didnt respect the eclipse.ini file.
My environment is:
IDE: Version: Neon.0 Release (4.6.0)
OS: Ubuntu 16.04.2 LTS
The installation routine java -jar lombok-1.16.16.jar works quite well. I.e. it adds the reasonable line -javaagent:<ABSOLUTE_PATH_TO_ECLIPSE_INSTALLATION>/lombok.jar to the eclipse.ini.
But if I start eclipse by using my desktop-shortcut, it starts without lombok (checked by looking at "Help"->"About Eclipse").
If I start eclipse by executing the executable eclipse next to the eclipse.ini file, lombok launches like a charm.
Hence I checked my desktop shortcut (e.g. ~/.local/share/applications/eclipse.desktop) and indeed, it started eclipse without reflecting the eclipse.ini.
Instead it uses something like /usr/bin/java -jar org.eclipse.equinox.launcher.jar ... to start eclipse.
So the solution was to replace the old Exec line in the desktop shortcut by:
Exec=/opt/eclipse/neon/eclipse
where /opt/eclipse/neon/ is the place where I have installed eclipse.
Antoniolazaro has given a solution for Eclipse Neon issue on MacOS
When I put the complete path, it works on Mac Os.
-javaagent:/Applications/Eclipse.app/Contents/Eclipse/lombok.jar
Resource Link:
https://github.com/rzwitserloot/lombok/issues/1173
And the lombok project owner rzwitserloot has given 3 suggestions for checking
Can you give us the complete path, from root, of your eclipse
install? Starting with 1.16.14, the installer should still find
eclipse even with the funky paths that the OOM installer comes up
with. I have no idea why the installer isn't finding your eclipse
automatically, here. I can't reproduce this on my mac.
The lombok uninstaller has the same 'find eclipses' capability as
the installer. Mac doesn't have a registry and we aren't going to
dump a bunch of crud in your homedir just to keep track of where we
installed your lombok; we like it that way: No cruft. So, that part
(that the uninstaller can't find a custom-install location and
requires you to again specify it) is not a bug.
You still have to add lombok.jar to your project as a dependency
same as any other third party dependency (something like guava, for
example). It's not clear from your problem description if you
actually did that.
Resource Link:
https://github.com/rzwitserloot/lombok/issues/1310
Even after following the below steps(try the steps given below first) , if it doesn't works, one issue can be that you are using the eclipse from the desktop , not from the folder where eclipse is installed. Running eclipse from the desktop sometimes is unable to load the .ini file, hence lombok won't run. So, try running the eclipse from the folder where you have installed it.
Steps:
1. Give the lombok dependency in the pom and build it.
The lombok.jar is usually downloaded in the folder .m2/repository/org/projectlombok/lombok/1.x.y
Install the jar in the folder "java -jar lombok-1.x.y.jar"
Then it will ask you to select the IDE. Browse to the eclipse installation
folder and select eclipse from there.
Now your eclipse installation folder, should contain the lombok.jar and eclipse.ini should contain the line
-javaagent: /lombok.jar
Run the eclipse from the installation folder. Clean and rebuild the project.
It should work now!
try #Data annotation for the class.
public #Data class user{
\\do stuff
}
For me, downloading the latest Eclipse Neon, i.e. Neon 3, fixed the problem
My environment is:
IDE: Version: Neon.3 Release (4.6.3)
OS: Ubuntu 16.4
It works for me when i do this steps below:
1. copy `lombok.jar` to where your eclipse folder where is the `eclipse.ini` ;
2. open `eclipse.ini`,put at end the two lines below with full lombok path and save it:
-Xbootclasspath/a:/DEV/Tools/IDE/eclipse/jee-neon/lombok.jar
-javaagent:/DEV/Tools/IDE/eclipse/jee-neon/lombok.jar
3. restart `eclipse` in command line (when i try run with exist link in launcher it's not work)
4. rebuild your projects
As far as I am concerned, I use a "Chocolatey" distribution of Eclipse on Windows.
It does not change much. But for those of you who are not admin of their desktop, it might be a hassle, because Chocolatey installs softwares in C:\ProgramData\... which is an "admin" directory.
In other words, you may need to modify your shortcut's property "start in" which will not be possible unless you are admin of your desktop.
The trick that worked for me here was to create a new shortcut, which has the correct "start in" property to start eclipse in the directory where the eclipse.ini is...
Then recompile using eclipse, then work on your project a bit until eclipse realizes that lombok was installed...
Cheers
After installing lombok, you need to copy lombok.jar into your project or add dependency in maven configuration xml file
exit the eclipse and then go to the eclipse directory and open eclipse.ini and add -clean on a top and rerun the eclipse. hope your problem is solved.
To elaborate on the above replies:
PROBLEM:
In my scenario:
I installed SpringBoot STS under Eclipse Photon,
I created aSpring Boot/Gradle build project, and I got the "undefined method" error using Lombok #Data.
Environment: Ubuntu Linux 18.04.
SOLUTION:
cd ~/.gradle/cache/.../lombok/...;
java -jar lombok-1.16.22.jar
NOTE:
java -jar lombok*.jar brings up a GUI that
Allows you to select which Eclipse install to update.
Updates eclipse.ini AND...
Copies lombok-xyz.jar into the Eclipse install folder, as lombok.jar.
Eventhough there are already a lot of answers here none of the given answers solved my problem, so I'll add my information here as well in case it might help someone:
My setup is:
Win10 Home,
Eclipse Version: Oxygen.3a Release (4.7.3a),
Eclipse Build id: 20180405-1200,
Add lombok to my pom.xml
mvn clean install
close eclipse
navigate to my .m2 folder .m2\repository\org\projectlombok\lombok\1.18.6>
run: java -jar .\lombok-1.18.6.jar (or whatever version you have
Install lombok
Now it's getting intresting. The installation added the following to my eclipse.ini:
-javaagent:lombok.jar
How ever it placed them at the bottom of my .ini file. So it looked liked this.
--launcher.appendVmargs
-vmargs
-...
--add-modules=ALL-SYSTEM
-javaagent:lombok.jar
I assumed that -javaagent:lombok.jar belongs under -vmargsso I put it at the bottom of --launcher.appendVmargs. That didn't work either though. But when I put -javaagent:lombok.jarright below vmargs it works. Ultimately my eclipse.ini looks like this:
--launcher.appendVmargs
-vmargs
-javaagent:lombok.jar # lombok works for me if this is here
-Declipse.p2.max.threads=10
- Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=#user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
#-javaagent:lombok.jar | lombok doesn't work for me if its placed here.
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
Not sure why this issue orcurrs but maybe it helps you. If you are under macOS remember to add -Xbootclasspath/a:lombok.jalike other answers in this thread suggest.
I have faced this issue recently and all the above solutions mentioned by the above users didn't work. The problem I have was there are special symbols like '$' in path(This can be found in last line of eclipse.ini file) to eclipse. Due to the same reason lombok cannot identify the file and append the necessary two lines in eclipse.ini file. Removing the special characters like '-' , '$', '_' in my eclipse path fixed mu problem
For, after installing lombok like mentioned above I had to do right click on your project folder -> Run as -> Maven clean. Ne the .jar is deteced and properly used
Copy and paste the lombok jar into the eclipse installation folder.
Run the command "java -jar lombok-.jar".
A GUI opens.
Check the IDE listed in the installer.
This entry should be available in the eclipse.ini file "-javaagent:<>".
Restart Eclipse to find the changes which starts listing the associated getters, setters in your java file.
Simply add to eclipse.ini file this statement (or check if you have):
-Xbootclasspath/a:lombok.jar
-javaagent:lombok.jar
Attention please, usually you have only:
-javaagent:lombok.jar
Obviously restart your eclipse
For Eclipse neon on Mac (High Sierra) :
Use lombok version 1.16.14 or above.
Installer launches by running (double clicking) lombok-1.16.14.jar file itself. It should detect installed versions.
On the Mac, it detects Eclipse.app only from Applications directory. If not, you can tell the jar where to find it in the popup dialog. Note that you should point it to eclipse.ini file (Eclipse.app -> Show app contents -> eclipse -> eclipse.ini)
Lower versions of lombok do not work on High Sierra. They don't detect installed eclipse instances.
Finally remember to restart eclipse (via File -> exit) and run maven update project.
I might be late to reply here but for future references adding this answer,
Please don't use Lombok v1.18.14 as it will crash eclipse. It is mentioned in changelogs. Use next version v1.18.16.
Simple way to setup lombok to eclipse is mentioned in this answer https://stackoverflow.com/a/69332138/3637115
Ok im wondering where does xamarin get this path from?
Severity Code Description Project File Line Source Suppression State
Error The specified task executable location "C:\Program Files (x86)\Java\jdk1.7.0_71\\bin\javac.exe" is invalid.
So I can go and change it to the new jdk1.8. I have the new JDK set up I just need to know where to change the path at.
I had the same problem and solution is.
Remove all jdk and install jdk 1.8
Change reference java location in Visual Studio Tool > Options > Xamarin
Clean and Rebuild Project
I've just solved this exact problem for me.
I don't know why you wouldn't have a JDK_HOME variable. Completely remove the JDK and install it again maybe?
The Environment Variables for java were set to my previously installed path. I guess Oracle screwed up here.
As I had the same error, here's what I did:
I went to C:\Program Files\Java\ and checked what the jdk folder is called. For me it's jdk1.8.0_102.
For users who don't know where to find System Variables:
Go to System Properties and on the left hand side, click Advanced System Settings. Switch to the Advanced tab, click Environment Variables. Under System Variables there should be two variables in the list called JAVA_HOME and JDK_HOME.
I edited those values and change the path to what I found in the java folder. In my case this would be C:\Program Files\Java\jdk1.8.0_102.
No need to close VS, just build your app and it should get passed the annoying error.
Hope this helps :)
I had exactly the same problem. I got it to go away (which is not the same thing as fixing it).
Un-install every bit of JAVA you have. Delete both JAVA folders (Program Files and Program Files (x86)).
Install the latest version of the Java (x32) SDK.
Clean and Rebuild your project(s).
Since my Solution is multi-platform, I changed the Startup Project to the .iOS one, built it, ran it in an emulator, and set the Startup Project back to the .Droid project.
Somewhere in all this, the problem went away.
And remember kids! If it can go away all by itself, it can come back again all by itself!
I had this issue as well, I downloaded 32 bit Java but VS was still looking for the 64 bit one.
To solve it all I had to do was change the JAVA_HOME and the variable in my Path, clean my project and rebuild it.
Just set JAVA_HOME and JDK_HOME ambient variables, clean your solution and build again. For me worked fine.
Don't forget to clean your solution.
I was trying to upgrade from Maven 2 to Maven 3.1 on os x mavericks. I tried using brew install maven, thinking it would upgrade maven to the latest version. However that didnt help. It showed the same No such file or directory message. Following this,I uninstalled the maven(installed through brew) by doing brew rm maven.
However, now I cannot seem to get back either version of maven when I try mvn -v, I get thhe output
-bash: /usr/local/bin/mvn: No such file or directory
The following is the content of my bash_profile
export M2_HOME=/usr/local/apache-maven-2.2.1/
export JBOSS_HOME=/Applications/whp-jboss-cluster-5
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/
export TOMCAT_HOME=/Library/Tomcat/
export PATH=$PATH:$M2_HOME/bin:$JBOSS_HOME/bin:$JAVA_HOME:$TOMCAT_HOME
Any idea on how I can fix this and get to maven 3 would be appreciated.
It looks like you have all of the necessary ingredients. You simply need to source your profile so that those changes take effect. (You can do this with . ~/.bash_profile.)
It is possible that your shell cached a previous version of mvn. This can happen if you add an item to your path after something of the same name has been used before. In that case, as Etan pointed out in the comments, you can just hash -r, to clear things up. (This doesn't seem to be what you were seeing, but is worth trying in the future if you add maven 3 and mvn -version keeps showing version 2.)
To get Maven 3 running, it should just be these steps. Just, with your path having the maven 3 directory instead of the maven 2 one.
I am able to run a sample hadoop program from the command prompt and am trying to run the same program from Eclipse, so that I can debug it and understand it better.
For the command line program, some environment variables are set in the .bashrc and the same are being read as System.getenv().get("HADOOP_MAPRED_HOME") in the hadoop program. But, when I am running a java program with System.getenv().get("HADOOP_MAPRED_HOME"), from Eclipse I am getting null.
I tried passing -DHADOOP_MAPRED_HOME=test to VM parameters in the runtime configurations from Eclipse, but still getting null in the standalone program. How to make the environment variables visible within Eclipse? When I iterate through System.getenv() in Eclipse, I see lot of variables like DISPLAY, USER, HOME and others. Where are they set? I am using Ubuntu 11.04.
You can also define an environment variable that is visible only within Eclipse.
Go to Run -> Run Configurations... and Select tab "Environment".
There you can add several environment variables that will be specific to your application.
I've created an eclipse plugin for this, because I had the same problem.
Feel free to download it and contribute to it.
It's still in early development, but it does its job already for me.
https://github.com/JorisAerts/Eclipse-Environment-Variables
The .bashrc file is used for setting variables used by interactive login shells. If you want those environment variables available in Eclipse you need to put them in /etc/environment.
You can set the Hadoop home directory by sending a -Dhadoop.home.dir to the VM. To send this parameters to all your application that you execute inside eclipse, you can set them in Window->Preferences->Java->Installed JREs-> (select your JRE installation) -> Edit.. -> (set the value in the "Default VM arguments:" textbox). You can replace ${HADOOP_HOME} with the path to your Hadoop installation.
You can also start eclipse within a shell.
You export the enronment, before calling eclipse.
Example :
#!/bin/bash
export MY_VAR="ADCA"
export PATH="/home/lala/bin;$PATH"
$ECLIPSE_HOME/eclipse -data $YOUR_WORK_SPACE_PATH
Then you can have multiple instances on eclipse with their own custome environment including workspace.
I was trying to achieve this but in the context of a MAVEN build. As part of my pom.xml configuration, I had a reference to an environment variable as part of a path to a local JAR:
<dependency>
<groupId>the group id</groupId>
<artifactId>the artifact id</artifactId>
<version>the version</version>
<scope>system</scope>
<systemPath>${env.MY_ENV_VARIABLE}/the_local_jar_archive.jar</systemPath>
</dependency>
To compile my project, I had to define the environment variable as part of the run configuration for the maven build as explained by Max's answer. I was able to launch the maven compilation and the project would compile just fine.
However, as this environment variable involves some dependencies, the default "problems" view of Eclipse (where compilation errors/warnings usually show) would still show errors along the lines of Could not find artifact and systemPath should be an absolute path but is ${env.MY_ENV_VARIABLE}/the_local_jar_archive.jar.
How I fixed it
Go into Window -> Preferences -> General -> Worksapce -> Linked Resources and define a new path variable.
Finally, in my case I just needed to Right click on my pom.xml file, select Maven -> Update Project and the errors disappeared from the "Problems" view.
For the people who want to override the Environment Variable of OS in Eclipse project, refer to #MAX answer too.
It's useful when you have release project end eclipse project at the same machine.
The release project can use the OS Environment Variable for test usage and eclipse project can override it for development usage.
I was able to set the env. variables by sourcing (source command inside the shell (ksh) scirpt) the file that was settign them.
Then I called the .ksh script from the external Tools