Results 1 to 5 of 5
  1. #1
    357mag is offline Member
    Join Date
    May 2010
    Posts
    33
    Rep Power
    0

    Default Two things I'd like to understand in Java with Eclipse

    First off...I made a custom code template. A very simple and basic code template. So when I start a new project I don't have to re-type public class followed by the opening and closing braces. And I don't have to re-type public static void main and the opening and closing braces.

    I inserted this in the preview pane in the templates part of the preferences. But it did not stay.

    Eclipse didn't save it.

    Plus how do I call it up? Isn't there a way so when I start a new Java project I can go into a menu or right-click or something and call up my custom template and it will be right there in the editor window? I don't see a way to do this.

    The second thing is every time I create a new project Eclipse keeps putting these new projects in the left pane and I have the new project listed plus the old project is also listed.

    How do I only see the new project? I don't want the old project listed there or open. Do I need to tell Eclipse to always start a new workspace?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    25

    Default Re: Two things I'd like to understand in Java with Eclipse

    You can just close the other project(s).
    Right click and I think there's a close option.

    They'll still be in the list as they are part of the workspace, but you can't expand them unless you double click to reopen them.

    Can't help on the templates.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,189
    Rep Power
    12

    Default Re: Two things I'd like to understand in Java with Eclipse

    When you create a class within a project, you should see options to select whether its public, protected, etc. and also whether you want to have a static main entry point. So you don't have to type public or main, etc. To create a class file either use the File->new menu or just click on the create class icon.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    357mag is offline Member
    Join Date
    May 2010
    Posts
    33
    Rep Power
    0

    Default Re: Two things I'd like to understand in Java with Eclipse

    Quote Originally Posted by jim829 View Post
    When you create a class within a project, you should see options to select whether its public, protected, etc. and also whether you want to have a static main entry point. So you don't have to type public or main, etc. To create a class file either use the File->new menu or just click on the create class icon.

    Regards,
    Jim
    Well the problem with that is that most likely Eclipse will put the braces wrong. I don't put my braces the way some people and development environments do. I like to line them up all on the left side so they are vertically aligned.

    This is one reason for my template.

    I could type my template exactly how I want and just tell Eclipse to load it.

    But I don't see a way.

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,189
    Rep Power
    12

    Default Re: Two things I'd like to understand in Java with Eclipse

    Well, first, I may be able to help you a little with templates in general, but I don't believe they are necessary for this problem. I would assume (hope) that your braces are indented some amount for each block level. So if you want them both on the left, then I recommend you modify your coding styles section. Go to Window->preferences->java-code style->formatter. There you can set all kinds of formatting options. The
    braces tab let's you configure this for a variety of situations.

    If you ever import code or make a mistake in your formatting code while typing. You can type CTRL-SHIFT F to reformat your code based on you own style.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Java 2.5D Game, Don't Understand Some Things
    By augustas656 in forum New To Java
    Replies: 3
    Last Post: 04-06-2014, 11:52 PM
  2. Replies: 8
    Last Post: 02-20-2014, 01:30 PM
  3. Eclipse is doing weird things
    By Programmer 142 in forum New To Java
    Replies: 2
    Last Post: 11-29-2011, 11:42 PM
  4. What are some cool begginer things to do with Java?
    By CiniCraft in forum New To Java
    Replies: 2
    Last Post: 09-11-2011, 10:13 PM
  5. Replies: 6
    Last Post: 03-23-2011, 06:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •