Eclipse right click new project preferences - java

Well, honestly, it is a simple question I can't find on eclipse nor google.
I am a lazy dev and want to add the Maven Projectoption to my [right click]->New->(Maven Project). But can't find an option in the preferences. Every Javaproject I create is a maven project (DM FTW, YEA!)
In PHPStorm I can simply add/edit an entry in a config section and I am done. It gets added to any "New" context.
Can I do something like that in eclipse? Add completely new "New..." entries to create a templated new file type and (the original topic) can I add another menu entry without writing a plugin?
Thank you in advance!

open eclipse, then go to Window menu, select Customize perspective...
a windows appears. it has for tabs.
Tool bar visiblity
Menu visiblity
Command Groups Availablity
Shortcuts
select Menu visiblity tab, it will shows all menus with tree view.
then expand tree view of File then do same for the New which is sub tree of File.
now select All of those project types that you want, then click Ok.

The concept is:
new means creating a bare project begining from zero,
adding means import some project that you/other have/has started...
in eclipse import is the menu you need to click to, then maven, then select the proj option the best fits you...

Related

How to add project to Create Project Wizard in Eclipse

In Eclipse while creating new project, the following window opens (consider the area surrounded by red lines in the image).
From that we can select project as Java Project or as per our requirement.
Now my question is, is it possible to add Custom Java Project as a project template in select Project Wizard ? If yes, how?
I want to create (please look the area surrounded by black lines in the image) a project having the name IoTSuiteSpecification as a default Project template in Select Project Wizard with mentioned four files and package.
For example, while creating new project, IoTSuiteSpecification is there in Select Project Wizard. Let me know if you need more clarity.
As you did not provide detail about what function you want to implement. This answer will just focus on how to create a new project wizard, but not the functionality details.
In short: you need to write a plugin and install that on every Eclipse you want to have this function.
I would like to keep this answer short, so the following content assumes you have basic knowledge about Eclipse Plugin Development, and have already created a plugin project. If not, please refer to tutorials such as Your First Plugin or Google "Eclipse Plug-in Tutorial".
Step 1: Create an extension for your project wizard
Go to plugin.xml -> Extensions -> Add -> org.eclipse.ui.newWizards, choose the "New File Wizard" template, click next.
Name your Classes properly. I will call everything NewWizard. So the wizard class is NewWizard, and the wizard page class is NewWizardPage, etc. Do not care about the "File Extension" and "Initial File Name", we won't need them.
Click Finish
Step 2: Implement the classes
After the previous step, you will have a package containing the wizard classes you just created. It should have two classes NewWizard and NewWizardPage.
First, you need to customize NewWizardPage to provide controls for your user to specify information such as Project name, etc. Refer to org.eclipse.ui.dialogs.WizardNewProjectCreationPage for an example of how to create a new Project Wizard page.
When you gather information from user, you should do some setup of your new project. Open class NewWizard, and find the function performFinish. In this function you should create your new project and setup it such as adding project natures. org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard is the eclipse wizard for creating a new general project. It provides a good reference for how to do these. If you have no idea, read or just copy their code.
Step 3
That's it! Enjoy your new project wizard!
Examples
As an example, you can look at my project https://github.com/harperjiang/TeXDojo. This is a plugin I wrote for Eclipse to edit and compile latex files. It contains a complete project wizard implementation in the package LaTeXEditorPlugin/src/hao.tex.dojo.latexeditor.wizards

View Package Dependencies in Eclipse

Is there any way to view package dependencies in Eclipse? I seem to remember a long time ago that it was possible. I have a packageX and want to see what packages refer to it. Ie packageY references it, but not packageZ.
There seem to be some outdated plugins out there, for example Java Dependency Viewer, but the comments for the plugin say 'don't bother'.
If you mean a java package, there is a possibility: You right-click the package in the project explorer, select References → Workspace and get ... a list of almost no results.
Then you go into the search menu (the small triangle ▿ at the top right border of the search view), select "filters" and uncheck the "imports" box. Then all references to your package within your workspace should appear in the view.

Shortcut key to activate project explorer in Eclipse

I am unable to find out the shortcut key to activate the project explorer in eclipse. I usually use cmd+F12 key to activate the editor, however i have to rely on mouse to move to a project explorer.
Is there a shortcut key available for that ? If not can it be configured ?
Go to Window --> Preferences --> Click on General --> Keys. You will see
Now, below Scheme there is textbox, type project explorer. You will see
Select Show View from the grid. In Binding type the short key which ever you want. I typed Ctrl+Alt+Shift+Q. Then click on Apply and OK.
If you want to assign a short key and that short key exists then you will see in Conflicts: table.
Some useful shortcuts are
103 shortcuts
more shortcuts
By activate do you mean to open the project?
This shortcut is not set by default. Go to Preferences->keys and serach for open project and set shortcut of your choice.
But to apply this shortcut you will have to reach that project. So set a shortcut to reach Project explorer [same way as explained above] , use arrow keys to reach project and then use your open project shortcut. Easiest way use mouse :)
Customise the Show View dialog.
The Eclipse defaults don't include the Project Explorer view, so you must add that.
From eclipseonetips.com:
The Show View commands are activated by pressing Alt+Shift+Q, then the letter for the relevant view, eg. to navigate to the Package Explorer, press Alt+Shift+Q, P.
So pressing Alt+Shift+Q will cause the Show View dialog to pop up where you can select the view you want with the cursor arrows, the mouse or the P.
Follow the instructions given in Aniket Kulkami's answer and add Alt+Shift+Q,R to the Project Explorer Show View item. Then you will see the option appear in the Show View dialog along with the other views it's possible to navigate to, and R will select it.
It might also make sense for you to remove the P from the Package Explorer view so you can use it for the Project Explorer instead.
Press Ctrl+Shift+L to open the Key Assist. All key shortcuts are available in key assist, see what you need is available there or not

Can't run SWT app in Eclipse

I was following the tutorial that came in the Eclipse editor (click Help -> Welcome -> Tutorials). I worked through all the steps which were:
This cheat sheet shows you how to create a "Hello World" application
that uses the Standard Widget Toolkit (SWT). The application will
simply display an empty window to the user. If you need help at any
step, click the (?) to the right. Let's get started!
If you're not already in the Java perspective, in the main menu select
Window > Open Perspective > Java or click on the "Click to Perform"
link below.
Open the Import wizard from the main menu via File > Import..., and
select Plug-in Development > Plug-ins and Fragments. Click Next. On
the Import Plug-ins and Fragments page, select Import from: The
active target platform. Plug-ins and Fragments to import: Select from
all plug-ins and fragments found at specified location. Import As:
Projects with source folders. Click Next. On the Selection page, Add
org.eclipse.swt.{platform}.{os}.{arch} (for example:
org.eclipse.swt.win32.win32.x86 for win32) to Plug-ins and Fragments
to Import: list. Click Finish. This will create the
org.eclipse.swt.{platform}.{os}.{arch} project which we will need to
compile and run the application.
Now we need a project to store our own source code. In the main
toolbar, click on the New Java Project button, or click on the link
below. Enter HelloWorldSWT for the project name, then click Finish.
Since our project requires SWT, we need to specify this in the project
properties. Right-click on the project and select Properties. In the
Java Build Path page open the Projects tab, add the
org.eclipse.swt.{platform}.{os}.{arch} project, then click OK.
The next step is to create a new class. In the main toolbar, click on
the New Java Class button (or the link below). If not already
specified, select HelloWorldSWT/src as the source folder. Enter
HelloWorldSWT for the class name and select the checkbox to create the
main() method, then click Finish. The Java editor will automatically
open showing your new class.
In the Java editor, enter the following Java code in the main()
method: Display display = new Display(); Shell shell = new
Shell(display); shell.setText("Hello world!"); shell.open(); while
(!shell.isDisposed()) { if (!display.readAndDispatch())
display.sleep(); } display.dispose(); You will get compile errors.
Right click in the Java editor and select Source > Organize Imports,
then save your changes.
To run your application, right-click on your class in the Package
Explorer and select Run As > Java Application. A new empty window
should appear with the title "Hello world!". Congratulations! You have
successfully created a Hello World SWT application!
And here's a screenshot:
But when I tried to run the program, instead of displaying a blank screen as expected, it dumped this in the terminal:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-cocoa-4233 in java.library.path
no swt-cocoa in java.library.path
Can't load library: /Users/devenkelling/.swt/lib/macosx/x86_64/libswt-cocoa-4233.jnilib
Can't load library: /Users/devenkelling/.swt/lib/macosx/x86_64/libswt-cocoa.jnilib
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:331)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240)
at org.eclipse.swt.internal.C.<clinit>(C.java:21)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:101)
at HelloWorldSWT.main(HelloWorldSWT.java:11
I'm using an x64 system with the 64-bit Eclipse installed and both 32-bit and 64-bit versions of Java (I think). Please help. Thanks.
Source: Eclipse Forums
This worked for me:
Right-click on your your project folder HelloWorldSWT;
Go to Properties -> Left Sidebar Java Build Path -> Tab Projects;
Expand the org.eclipse.swt.cocoa.macosx.x86_64 folder by clicking on the arrow left to it;
Select Native library location and click Edit;
Click the Workspace button and select org.eclipse.swt.cocoa.macosx.x86_64;
Click OK a couple of times;
And you're done! Hope this helped.

How to import existing project into Workplace in Eclipse?

I am trying to follow Eclipse instructions to create a Hello World SWT application. I have the following instruction:
Import the SWT project from the main
menu via File > Import..., and select
Existing Projects into Workspace.
Specify the archive file you
downloaded and click Finish. This will
create the org.eclipse.swt project
which we will need to compile and run
the application.
I have troubles with that. In the "File" menu I see "Import...". When I click the "Import...", I do not see "Existing Project into Workspace". Instead of that I see "Select an import source:" after which I see a text field. After that I see a field with the following folders: General, CVS, Run/Debug, Tasks, Team, XML.
Can anybody help me with that, pleas?
You need to expand General.
If you expand the 'General' node (folder) you will see 'Existing projects into workspace' as an option. Select that and click on Next.
Eclipse has the wonderful search functionality on most of its important screens. Even if you don't know where exactly it is, you can type it and it appears. In this case type "Existing" into the text field above the list and you'll see what you are looking for.

Categories