I have done Android and C development in my copy of Eclipse, but have never actually done Java strictly. When I add code that compiles using "javac codename.java" to an eclipse project, eclipse gives me errors and can't recognize statements like import java.io.* . I believe this is due to a problem with my class path and I have tried adding some paths like library/system/java but have not had any success. Any ideas for a solution?
If Eclipse is having troubles with classes delivered by JDK, I would suggest checking out if it (thus - JDK) is properly installed. You may do that by going to menu Window > Preferences and started typing "jdk" in search input. It should point You to Java > Installed JREs. Check if there is proper JDK installed (if not - You may add it there).
After that try to clean Your project - menu Project > Clean....
Hope this helps, regards.
If you go into the preferences dialog and go to Java/Installed JREs, make sure those paths are correct.
In order for Eclipse to recognize source files as Java and compile them, your project has to be a Java project. Putting a .java file in a project that wasn't created via New / Java Project won't work.
Please try creating a Java project and put your .java file in it.
On os x the default location (right now anyway) is /System/Library/Java/JavaVirtualMachines/[VERSION].jdk/Contents/Home
The default location is available from /usr/libexec/java_home.
That said, I've never had any problems with eclipse not finding the jdk, usually it's all
automatic.
Related
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 have the JD-eclipse-plugin installed. I want to decompile the classes within a jar-file. So I select the jar-file within Project-Explorer and click Decompiler in the Menu. However both decompilers (JAD and JD-core) are greyed out.
I also tried the steps shown in this blog on AVAJAVA Web Tutorials. I guess the blog is a bit outdated, however I can see within Windows-->Preferences-->Java-->Decompiler that Jad is correctly set up. But there is no JD-eclipse found within Preferences-->General-->Editors-->File Associations as you can see in the following image.. Now I right click the jar-file within Project-Explorer, but there is no such "Attach Source File".
Did I miss anything to set up the plugin?
EDIT: I´m using the following setup: Eclipse: Mars.1 Release (4.5.1); JadClipse 4.0.0; JDK 1.8
EDIT2: Forgot to mention that I use Tomcat and want to dive into the libraries from /WebContent/WEB-INF/lib. This is not working, I cannot further collapse the jar-files.
For Eclipse 2018-09 , the problem was related to " class without source
"
I had resolved this issue by going to:
Preferences
General
Editors
File Associations
Class without source
and setting decompliler viewer as default : see the following screen shot:
Obviously I mixed the actual JD-eclipse-plugin an a plugin called JadClipse for Eclipse which is a slightly different plugin from eclipse marketplace. Thus when I followed the installation instructions of JD-eclipse, I could set the options for the screenshot posted within the question. So I set JD-eclipse as default for both *.class-files with and those without source-code.
Second mistake I did was a pretty silly and obvious one, namely that I wanted to browse the jar-files from within WEB-INF-folder of my Tomcat instead of from within Java Resources. Thus I could not dive into the jar-files at all hindering me to get to the class-level and thus to decompile those classes contained within the jar.
I hope this helps anyone outside also having trouble with the plugin for eclipse.
I had the same problem but "class without source" did have decompliler viewer as default. So all I did was set class file viewer as default and then switched back and that fixed the issue.
I had to update all of my plugins. the Procyon decompiler has this symptom when running under java 11 or later.
I am using PyDev for Eclipse as my IDE and pip as my package management tool, running virtualenv.
Every time I want to use/include some new libraries or new dependencies in my project, I add them into the pip-requires file. The dependencies are installed in my virtual environment with no problem after running pip install -r pip-requires.
My Env:
Ubuntu 12.04
PyDev for Eclipse 2.7.1.2012100913
Python 2.7.3
Eclipse indigo
Update: My Pydev Setup:
Questions:
eclipse/pydev knows nothing about the new libraries being added in my virtual env. I had to manually add the .egg source folder into eclipse project's PYTHONPATH one by one in order to resolve all the unresolved imports which was very annoying! Can the python dependencies be resolved in a easier manner?
Update:
I found that if I use virtual env Env/bin/python as the interpreter as the screenshot indicates, some of the basic modules are not resolved in eclipse, eg. import copy, import json etc. should I use default /usr/bin/python as interpreter and just add virtual env site-package to the PYTHONPATH? so that I can resolve both standard python libraries(eg. json) and my own project dependencies?
Make sure your system PYTHONPATH include the site-packages folder when you choose python interpreter from your virtualenv. Just like the snapshot.
Then you don't need to add them one by one into PYTHONPATH. You will need to restart eclipse (Refresh doesn't work). New models will be added.
Update:
I checked the PYTHONPATH in the virtualenv. I found there are some other paths in the sys.path. They are the system default python installed location. These path includes the basic models, like copy and json.
PS: My environment is Max OSX 10.8. Please check the output of your own platform by print sys.path
/Users/username/.virtualenvs/test/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
/Users/username/.virtualenvs/test/lib/python2.7/site-packages/pip-1.1-py2.7.egg
/Users/username/.virtualenvs/test/lib/python27.zip
/Users/username/.virtualenvs/test/lib/python2.7
/Users/username/.virtualenvs/test/lib/python2.7/plat-darwin
/Users/username/.virtualenvs/test/lib/python2.7/plat-mac
/Users/username/.virtualenvs/test/lib/python2.7/plat-mac/lib-scriptpackages
/Users/username/.virtualenvs/test/lib/python2.7/lib-tk
/Users/username/.virtualenvs/test/lib/python2.7/lib-old
/Users/username/.virtualenvs/test/lib/python2.7/lib-dynload
/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/Users/username/.virtualenvs/test/lib/python2.7/site-packages
I think this is the requirement of virtualenv. You need to add these paths into pydev system PYTHONPATH. Then you can use these basic modules.
From your questions I understood that you're manually adding the Python Egg packages to the path. Instead of doing this, you can just go to the Project Settings window, then open "PyDev - PYTHONPATH", navigate to the panel called "External Libraries" and add the whole site-packages folder of your virtual environment, usually /path/to/virtualenv/lib/site-packages/. This way you won't add the Eggs one by one for each packages. When you install a new package, just go to the Eclipse window and if the import is still not resolved, select the project and press the F5 key, to refresh the project.
Hopefully, that should work for you. Good luck.
This is how I go about setting up PyDev with a virtualenv:
Create a virtualenv at /home/anshumanb/.virtualenvs/myvenv
In Eclipse, Window > Preferences > PyDev > Interpreter - Python, I add a new interpreter. For the interpreter executable, I point it to the virtualenv's Python i.e. /home/anshumanb/.virtualenvs/myenv/bin/python
In the "Select folders to be added to PYTHONPATH" screen, I select all the paths starting with /home/anshumanb/.virtualenvs/myvenv AND
/usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk and nothing else.
(See this for why I select /usr/lib/python2.7, /usr/lib/python2.7/plat-linux2 and /usr/lib/python2.7/lib-tk)
When I'm back at the Interpreter - Python screen in Eclipse preferences, I hit Apply then OK
After this, whenever I install any packages into the virtualenv, I go back to the Interpreter - Python screen, hit Apply, select the interpreter that points to my virtualenv (and the one I just installed packages into) and hit Apply. PyDev then picks up any new packages installed in the virtualenv.
Note: I'm using PyDev 2.7.1 and Python 2.7.3 but on an Arch Linux box with Eclipse 4.2.1. But I don't think it'll make any difference.
I wrote a project in eclipse with an older version of java.
Now on a different computer but running the same codes I'm getting a whole lot of red.
This is due to Version incompatibility.
I've had my professor change the Java version from within the console window before. The code compiled just fine after he did so. I'm sure its the same case with this code.
After looking at other tutorials and google links I could only find command line approaches and #override methods. To be honest I still don't understand these.
What is the best way to change the version of a code originally written in an older code inside the eclipse console?
thanks!
In eclipse go to Window -> Preferences -> Java -> Compiler, there you can change the java versions. Hope it helps.
Ideally if we want to have two different versions of Java [say 1.6 and 1.7], then we should have two workspace defined accordingly to avoid any mixup. We can also change the Project Facets if our projects has facets that is.
In Eclipse Follow steps given below:
1) Windows -> Preferences -> Java -> Compiler and as per the image set the compliance compiler level as per your requirements.
2) Windows -> Preferences -> Java -> Installed JRE's and check if your required jre/jdk is available or not as given in image below:
3) Right Click on Your Project and go to Java Build Path and check if your required Library is available or not as per image given below:
4) Now you can edit the JRE System Library or add one by clicking on button's available on last image's right side, then a pop up as given below will open up. Here, you can change the execution environment [default values also can be set]
In myeclipse select the project -> properties -> java compiler -> there you can specify jdk version.
Easy
Download the jdk from Oracle's official website for the version you want to compile your project with.
JDK Oracle's official
create a new Java project
[
Once the project has been generated, If you select the part that says Configure JREs
By default eclipse will use the version you have installed on your system so if you don't change this configuration you will never be able to run the program with the build you need, in this case I will use jdk 1.8.
After pressing Add
5.1 And choose the option select the 3rd option in this case, called Standard VM and press Next
Now eclipse asks us to indicate the path where the libraries and other content is located in order to compile and run the program, we only have to indicate the directory where it is located.
As my goal is to run a program with the JRE 8 , I will look for the directory path where the download described in option 1 of this message is located.
As a quick example, since I just want my program to compile without worrying about anything else, I will add all the contents of my address.
Now we change by clicking on the JRE we want to compile our program, to be changed to the original default so that the new selection is executed ; and finally we press Apply and Close and Next
Press Finish to create the project
Now we have the whole project with all the necessary content to compile and run it.
Personally I think this is the quickest and cleanest way to do it ; the problem I encountered when I changed JDK is that when compiling I couldn't find the directory with the necessary components to run it, you had to download it and configure it together with the default parameters, which can cause a lot of headaches for less experienced users.
Finally, this is the version of eclipse that I am using
I hope you find this system useful, I use it to be able to run old examples that use applets , which are obsolete classes and jvm does not compile.
I'm building an Eclipse RCP application against Eclipse 3.7.1 and Java 1.6.
I'm also using Tycho to build, and have set up my RCP according to the Tycho tutorial from the EclipseCon 2011, to which I've stuck slavishly, apart from project names.
The application builds fine up until I get to Step 5 (adding a p2 repo, then adding a .product file. Well, it still builds fine, and everything is where it should be, but I cannot start the RCP by clicking on the .exe file from the repository in the workspace.
All I get is the old dreaded "The [RCP] executable launcher was unable to locate its companion shared library" error popup.
First of all I thought I might have set up the CLASS PATH incorrectly, but when I open a console and type javaw or java -version anywhere, it all works.
Also, when I go to the pluginsfolder in the p2 repository for the RCP in the workspace, and double-click on org.eclipse.equinox.launcher_1.2.0.v20110502.jar, the RCP starts, albeit without the splash screen.
This must surely mean my Java set up is correct, and it's not a class path problem?
I'm not sure where this problem might lie (I have a plugin, a feature, a product, a repository, and a parent package with the main pom), so if you let me know your suspicions where the error might come from, I'll be more than happy to post respective XML, build.properties, screenshots and what have you. Unless this is a common error with a common solution.
Many thanks in advance!
Oh yea: Windows 7 (64-bit), JDK and JRE both 64-bit as well, Eclipse EE 3.7.1 (I chose that because it contains the most plugins I'll need later by default).
UPDATE
I'm attaching my CLASS PATH Settings for reference.
User variables
CLASS PATH: C:\Program Files\Java\jdk1.6.0_30;.;
System variables
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_30
Path: %JAVA_HOME%\bin;
UPDATE 2
When I let Tycho create a ZIP file in the p2 repository, and copy that from the repo to another location, unzip it and run the .exe, the application starts without problems. So I guess this query is partially solved, but I'd still be interested to hear why I wouldn't be able to start the application from the repository...
Today I came across the same issue. I guess you could find the solution here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=176084
In short, the problem in my case was, that the org.eclipse.equinox.launcher_1.2.0.v20110502.jar must be unpacked in the plugins folder under the folder name: org.eclipse.equinox.launcher_1.2.0.v20110502
... hope that helps!
In my case the error The [RCP] executable launcher was unable to locate its companion shared library was because my path was too long.
Same issue I was facing from yesterday. Today, I have changed path of project(git clone) and build it and able to run RCP executable.
I think this issue was because of path too long.