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

14 August 2014

Working with multiple jdk's on your local

I installed multiple jdk's on my local today. Played around a bit and figured out this is how I can easily switch between them!

> java -version:1.7 -version
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b19)

Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)


> java -version:1.8 -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)


If I want to use specific java version to run my eclipse, I will have to set the "-vm" variable in the eclipse.ini file like so:


-vm
C:\Program Files\Java\jdk1.8.0_11\bin\javaw.exe

Reference: 
1. multipe java on stackoverflow 
2. Eclipse - Specifying the JVM

03 July 2014

Eclipse keyboard shortcuts

Introduction to the dark art of Eclipse magic.

Ctr+Shift+L = Display all keyboard shortcuts

Ctr+M = maximises the current view
F4 = display type hierarchy

Ctr+Q = Take you back to your last edit
Alt+LEFT, Alt+RIGHT = navigate backwards and forwards on your last file views.
F3 or Ctr+CLICK = Take me to it's definition
Ctr+L = Jump to a specified line number
Ctr+E = Browse through a list of all the files that is opened in editor.

Ctr+F = Find/Search
Ctr+J = find as you type - incremental search
Ctr+Shift+R = Open a resource

Ctr+I = Indent code
Ctr+D = delete current line

Ctr+Shift+O = Organize imports
Alt+Shift+R = refactor - rename variable/method name.
Alt+Shift+S+R = refactor - generate getters and setters
Alt+Shift+M = refactor out a method

Play with these shortcuts. As you work on your IDE, there are frequent things you keep doing. Look for a keyboard shortcut for it. If you can't find it, then you search for it and create your own in the Preferences window. 
You can open it by Ctr+Shift+L and again Ctr+Shift+L. 

Something I made up
Ctr+Shift+F = File search

Happy typing.

Reference - http://web.stanford.edu/class/cs108/handouts132/10EclipseGuide.pdf

07 July 2009

Django using Eclipse with pydev extension

This article helps you configure eclipse so that you do web app development using django framework. Eclipse can be used for python programming using pydev plugin. The same plugin will be used for working with django framework also.

I assume you already have pydev plug-in for your eclipse. If not you can download it here. I assume that you have already installed django. If not you can download it here. Django installation instructions are here.
  1. Create your django project folder using the command line method as illustrated in the django tutorial. I assume you have used the project name as "mysite". For reference, I will consider it as located at "documents/mysite".
  2. In eclipse go to windows>preferences and then select Pydev>Interpreter-Python. Select the python interpreter (python dot exe). In the System PYTHONPATH section, please select the django folder you installed. Click Apply. Then click OK.
  3. Create a pydev project called "mysite" with src folder. For reference I will assume the project folder will be at "eclipse_workspace/mysite".
  4. Copy the entire "mysite" folder from "documents/mysite" and paste it into "eclipse_workspace/mysite/src" folder. Refresh your view in eclipse. You should now be able to see mysite package and polls package in the eclipse package explorer.
  5. Lets set up some run configurations. Go to Run>Run Configurations... In the Run Configuration window, select Python Run on the left. Right click and select New. Name it as "manage_config". Select the project as "mysite" and Main Module as "manage.py". In "arguments" tab, add "runserver --noreload" in Program Arguments section. In "environments" tab, add variable DJANGO_SETTINGS_MODULE with value mysite.settings. You can add new variables by clicking on "New..." button. Now you can run the manage.py module, and this will start the django inbuilt development server. If you want to debug the app, run the manage.py module in debug mode. Just right click on manage.py and then select debug>debug configurations and select manage_config. Click on debug. Or right click on manage.py select debug as> python run, if you have only one run configuration defined for manage.py

  6. Create a package called "test" and a module called "test". Use this module to play with your Django API. Lets set up some run configurations for test module. Go to Run>Run Configurations... In the Run Configuration window, select Python Run on the left. Right click and select New. Name it as "test_config". Select the project as "mysite" and Main Module as "test.py".

    In "environments" tab, add variable DJANGO_SETTINGS_MODULE with value mysite.settings. You can add new variables by clicking on "New..." button. Now you can run the manage.py module, and this will start the django inbuild dev .

    Now you can run or debug the test.py module and play with the Django API to your hearts fill.

    Please feel free to test drive and let me know if you run into issues. This set up is pretty much independent of version numbers. If you have any specific problem with any specific version combination, please leave a comment.