Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Tuesday, June 12, 2018

Eclipse XML file Syntax colors

If you have an XML files that opens with unreadable colors but the XML colors are different, the reason could be that the file is not associated to the XML editor but some other (default) editor, like Ivy.
Either open the file with (Open with...) the XML editor or change the color scheme for the default editor.

Tuesday, June 10, 2014

Building with Ant from Eclipse: "Specified VM install not found"

After an update of the JDK and successive removal of the old version, when I tried to build with Ant from Eclipse I got:

Specified VM install not found: type Standard VM, name jdk1.7.0_55

Yeah, right, OK, but where do I update the JDK that's used by Ant??
Here:
Run -> External Tools -> External Tools Configurations -> JRE

Thanks to Michael Borgwardt

Thursday, April 24, 2014

Specified VM install not found: type Standard VM ...

Specified VM install not found: type Standard VM, name jdk1.7.0_45

You installed a new JDK, configured Eclipse to recognize it but the old one still pops up when you compile or do something else.
Try removing the following file: \.metadata\.plugins\org.eclipse.debug.core\.launches\projectname build.xml.launch

Thanks to Mujahed

Friday, February 21, 2014

Annoying Eclipse Validation Errors

Sometimes you run into these Unknown validation errors in Eclipse which you seem not to be able to get rid of.
The Maven build is running fine even from within Eclipse but the messages won't go away even if you:
  • Right-click on the project --> Validate
  • Project --> Clean
  • Close and re-open it
What worked for me is: select them all, right-click and delete them.
If there was no real reason for them to show up because in the meantime you had removed the reason for them to exist, then they'll not be generated again.

Thanks to pelotom!

Monday, April 15, 2013

Add Installed JDK to Eclipse

If you install a JDK yourself (from a BIN, ZIP or other archive) you can easily add it from Window --> Preferences --> Java --> Installed JREs, choosing Add --> Standard VM and specifying the root directory of the newly unpacked installation.
If the JDK is already installed with the Linux standard directory structure, you should instead specify one of the directories you can find in /lib/jvm.

Create an Eclipse Git Maven Java Project

You need to create a new Eclipse (Juno) Java project from a remote Git repository (like GitHub) managed by Maven (i.e. you already have a pom.xml for your project.)
  1. Make sure you installed a Git plugin like EGit.
  2. Click on File --> Import --> Git --> Projects from Git
  3. Then follow the instructions...
  4. Specify a URI for the repository source. This will end with a file.git.
  5. Select a branch.
  6. Local destination (<Git's_local_repository>/<project_name>)
  7. Select Import existing project.
  8. Select create Java project.
  9. Select Use custom location. This should be the local Git repository location.
  10. Mavenize it: right-click on the project's name --> Configure --> Convert to Maven project.

Friday, April 12, 2013

Export Java Syntax Coloring Preferences from Eclipse Juno

I just found out that trying to export just the Java syntax coloring preferences from Eclipse Juno doesn't work.
These are the color preferences you set from Window --> Preferences --> Java --> Editor --> Syntax Coloring.

Theoretically you should do a File --> Export --> General --> Preferences, select Java Code Style Preferences (I don't have a Syntax coloring item) and get them in your favorite file.epf
They should be included in those.

It doesn't work. But you can get them if you select export all.
I don't know if this is a bug or not...

Sunday, February 10, 2013

Create Maven Project in Eclipse from Existing pom.xml

If you want to create an Eclipse project from an existing pom.xml file, you cannot do it from the usual New --> Project ...

For some reason you need to import it:
File --> Import --> Maven --> Existing Maven projects

Maybe I'm wrong but with Ant you could create a new Ant project from an existing build.xml...

Wednesday, June 13, 2012

Weird Things With Spring, Eclipse and Tomcat?

Everything was working and now an action seemingly still properly configured from a controller is simply ignored?
It's not Spring's or Eclipse's or your sister's fault.
Check you inadvertently didn't start another instance of Tomcat.
That's what happened to me! And I don't have sisters to blame!

Friday, May 11, 2012

Eclipse Code Templates

If you'd like to have your own text additions to a new file upon its creation, you can customize the way it is created with code templates.
Go to Window --> Properties --> Java --> Code Styles --> Code Templates.

You can customize comments and code components in this way at Eclipse level or project level.

Wednesday, November 09, 2011

Maven + Subversion Enabled Eclipse Java Project

Updated - Apr 2013
What I want for my Eclipse projects is to be Java projects, allow content revisions with Subversion and be managed by Maven.

This is what I need to do.

Eclipse version: Eclipse Juno
Subversion plugin: Subversive
Maven plugin: m2eclipse (m2e)

Support for Subversion and Maven is now integrated into Eclipse.
  1. Choose Help --> Install new software --> Work with: Juno - http://download.eclipse.org/releases/juno.
  2. Expand collaboration and check the m2eclipse and Subversive packages. Install all required components.
  3.  Add the Polarion update site: http://community.polarion.com/projects/subversive/download/eclipse/2.0/juno-site/ (see step 1 for details) and install the Subversive SVN Connectors and a connector of your choice (I use SVNKit 1.7.4)
  1. Create a new project (Checkout Maven projects from SCM). Choose svn as SCM URL and type the URL. If svn does not appear in the list, check the global configuration under Window --> Preferences --> Team --> SVN --> SVN Connector. The connector you just installed must appear on that list.
  2. Once the project has been created, you might have a Java-Maven project only. If that's the case, to connect it to the SVN repository, right click on the project's name, choose Team --> Share --> SVN and follow the instructions to conncet your project to the SVN source.
Now you have a Java project checked out from a Subversion repository which uses a Maven repository to manage its library dependencies.
You can further configure Maven under Window --> Preferences --> Maven. In particular you can add an external Maven installation and change the location of the repository which defaults to the user's personal repository and not the global one.

Monday, August 08, 2011

Eclipse Startup - Crash on Fedora 15

For some obscure reason, the Fedora 15-packaged Eclipse doesn't include JSP syntax highlighting and I could find no easy way to add it (conflicting dependencies prevent that). So I resorted to the original TAR-GZ distribution. The problem there is with the OpenJDK. My Eclipse simply crashes on startup.
What you need to do is tell Eclipse to use Sun's JDK.
Open the eclipse.ini and add the path to the Java executable:

-vm
/opt/java/jdk1.6.0/bin/java

right before the -vmargs option.
More here.

[UPDATE] - Oh, the reason for the crash is not openJDK. It's a bug in Fedora. To circumvent it do the following:
  1. In Gnome3 the webkit library name changed to libwebkitgtk so you need to create one missing symbolic link: ln -s /usr/lib/libwebkitgtk-1.0.so.0 /usr/lib/libwebkit-1.0.so.2
  2. Add -Dorg.eclipse.swt.browser.UseWebKitGTK=true to the -vmargs options in eclipse.ini
More here.

Monday, March 08, 2010

Eclipse: Copying Preferences To a New Workspace

When I create a new workspace in Eclipse what I want every time is to have all my preferences from the other workspaces, first of all the color preferences. There is no apparent option in Eclipse to do that. File --> Import --> Preferences won't do that. Maybe it's hidden somewhere else.
I found an easy way to do that: simply copy the settings directory to the new workspace.
Preferences are stored in each workspace in:
/.metadata/.plugins/org.eclipse.core.runtime/.settings

Shut down Eclipse.
Copy part or the entire contents of that directory to the corresponding directory of the new workspace (after you've created it, of course).
Restart and you're done!

Monday, March 01, 2010

Turning a SVN Project into a SVN/Java Project

This will be needed for a Java project created with the type "from SVN source". It will not have a Java nature by default.

Add a Java nature to the project in .project:

<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>

Create the file .classpath with the JDK/JRE libraries (and optionally the default output directory):

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Then you might want to add to the classpath the libraries which could not be detected at creation time.

This method is alternative to the one detailed here.

Eclipse: Hiding Internal JARs

If you need to hide all the internal libraries your project is using, you can do so from the Package Explorer:
  1. Choose the view menu
  2. Check Show referenced libraries node
You can't do that from the Project Explorer (formerly Resource Navigator) since that is a view not reserved to Java projects.

Tuesday, July 28, 2009

Eclipse Losing Reference to JARs

I have this weird problem that every once in a while (especially upon checking in files to SVN/CVS but not limited to that situation) Eclipse will lose reference to class path JARs and start signalling errors everywhere in the code.
What I temporarily did to fix this was to remove a library directory from the [Project] Properties --> Java Build Path --> Source list of a project, save the properties, open them again and add it back in. Problem gone... for a while.

Now I'm trying something I read somewhere: start Eclipse with the -clean command line parameter.

I'll keep you posted...

Feb 2010 Update: with the current version of Eclipse I'm using (Eclipse Java EE IDE for Web Developers, Build id: 20100218-1602) this issue seems to be vanished.

Friday, July 03, 2009

No Javadoc When Hovering Cursor Over Text in Eclipse

I had this weird problem that no javadoc preview showed up when hovering the cursor over java code in Eclipse.

Eclipse version: eclipse-java-ganymede-SR2-linux-gtk
OS: Linux (Fedora 11)

I didn't find out why it didn't work but I found out that it was specific to the version of Eclipse I was using.
When I upgraded to Eclipse Galileo (eclipse-java-galileo-linux-gtk), with exactly the same configuration files and preferences, it worked straight away.

I guess it was a bug of the Ganymede SR2 then...

Friday, June 12, 2009

Unable to Start Eclipse On An Empty Workspace

OS: Fedora 11
Eclipse Version: 3.4.2, Build id: M20090211-1700

If I try to initialize a new workspace (empty but with an existing directory), Eclipse will open as an empty non-killable window.

I was able to have a "dirty" initialization copying the .metadata directory of another workspace I had previously and mysteriously created to the new workspace.

I need to experiment a bit more to see if it's possible to, for example, just create the .metadata directory...

Thursday, May 28, 2009

Eclipse: Could not launch the product...

Eclipse crashed or in my case took too long to open a file and I had to shut it down in a not clean state (really surprised it didn't crash during my attempt AND I didn't have to kill it! Great job people@eclipse!).
Next thing that happens when I try to re-launch it using the same workspace is an error message:

Could not launch the product because the associated workspace is currently in use by another Eclipse application

You need to:
  1. go to the workspace home directory
  2. enter the .metadata directory
  3. remove file .lock
and you can happily restart from where you left your job.

Thursday, May 14, 2009

JUnit, log4j And Eclipse

If you want Eclipse to pick up your log4j configuration file when you run JUnit tests from within Eclipse you can:
  1. Right-click on a test class.
  2. Select Run as --> Run configurations...
  3. Select the Classpath tab
  4. Select the home directory of you project and Advanced
  5. Then Add folder and add the folder with the configuration file and you're done.
This will configure the test file's JUnit run options.

If you want to configure all test classes with the same optoins... uhmm... stay tuned. I'll be back.