1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting Started with Eclipse

Discussion in 'Developers Corner' started by TiVoPony, Feb 15, 2005.

  1. TiVoPony

    TiVoPony New Member

    2,194
    0
    May 11, 2002
    Alviso,...
    Want to write an HME app? Maybe you've dabbled in code before, but never Java. It's not hard, but getting the tools to work is always the first hurdle.

    Want to get started? Here's one way, and it won't cost a penny. Note that I won't go into all the why's, but rather focus on the how's...let's get you up and running. :)

    First, download the following:

    The Java SDK 1.42 from java.sun.com

    The HME SDK from tivohme.sourceforge.net

    The Eclipse IDE from www.eclipse.org

    Install/unzip all of that into a set of directories. Doesn't matter where. But remember where you put 'em.

    Fire up Eclipse. You'll want to go back to eclipse.org and read through the first couple of sections of the faq, there's a link right on the front page. Work your way down to 'How do I write a "Hello World" program?. Try that...get that working first. It'll show you some of the basics.

    Now let's try the same thing with HME.

    Create a new project (you should probably go ahead and 'close' your old project by right-clicking on it and selecting 'close'). Name it anything you want. Eclipse will create it, and automatically add the JRE System Libraries to it (standard Java libraries).

    Now Right click on the new project (in the explorer window on the left side of the screen), and select Properties. Go to Java Build Path. Select Libraries. Select Add External JARs. Browse and find the files named HME.jar and hme-host-sample.jar in the HME SDK directories. Select both of those, press OK, and Eclipse will add the hme.jar and hme host libraries to the project too.

    Create a new package within that project. You can name it whatever you want...our guys use com.tivo.hme, you can use anything, just try to make it unique to you. All lower case. This creates a hierarchy of folders within your eclipse 'workspace' folder, matching whatever you type (eg. empty 'hme' folder inside a 'tivo' folder inside a 'com' folder.

    Create a new class within that package. Name it HelloWorld (mind the capitalization, java is picky). Eclipse will create a new class and will auto-fill a bunch of information for you...the start of a program. Select it all, and delete it.

    Open up the sample HelloWorld.java app from the HME SDK using any text editor. Copy everything from there into the new class you created in Eclipse (replacing the auto-fill stuff).

    Find the line near the top that says 'package com.tivo.hme.samples.HelloWorld'...change it to say 'package xxx.yyy.zzz' where xxx.yyy.zzz is the name you gave your package earlier. All lowercase.

    One more thing and you're ready to try and run this thing. You need to copy the icon file from the HME SDK directories to the package. This is easy. Just go to 'My Computer' or 'Windows Explorer' or whatever you use to browse files on your PC. Go to the HME SDK directory you created, and dig through to where the source (src) for the samples are. In the directory called Hello you'll find an icon.png file. Drag that over to the package icon you created in Eclipse. The file will be copied into the Eclipse directories for your java project.

    Now, select 'Run' from the menu bar, and scroll down the drop down window and select Run... Don't choose Run As!

    A Run window will open. Click on Java Application (to the left), and then press the 'new' button. It'll create a new file labeled 'New_configuration'. Highlight it. This is the runtime configuration for this particular program. Change the Name: to something that makes sense (like HelloWorld). The Project name should be auto-filled. Below that is Main Class. Make sure that 'Include external jars when searching for main class' is checked on. Type the following into the Main class dialog: com.tivo.hme.host.sample.Main.

    Now click the 'Arguments' tab (still in the Run dialog window). Under 'Program Arguments' type the packagename.classname (eg. com.tivo.hme.HelloWorld, or xxx.yyy.zzz.HelloWorld). That's the packagename followed by the classname...you need both this time.

    Remember to pay attention to capitalization.

    Now click 'Run'.

    You should see a console window open at the bottom of the screen, and it'll say something like this:

    1062ms: Registered http://192.168.3.6:1247/hme/
    1140ms: 192.168.3.6 handleHTTP: /hme/icon.png

    You can either double click the simulator.jar file in the HME SDK directories, or go to 'Music, Photos & More' on your TCD and view your application. The backdoor for turning on MP&M is clear clear 0 0 on the System Info screen.

    If you can get through the above, and you see "Hello World" on your TV...you did it! Now you can focus on learning Java, rather than trying to make the tools behave. :)

    Cheers,
    Pony

    edit - updated to reflect the new hosting implementation in SDK 1.3+
     
  2. martinp13

    martinp13 YHTBMABIITY

    10,976
    0
    Mar 19, 2001
    Fort Worth, TX
    Thanks Pony... always nice to have a lantern to help guide you through the swamp! :) Can't wait to get home and give this a try.
     
  3. dropd

    dropd New Member

    245
    0
    Dec 22, 2003
    Good job Pony. Eclipse is definitely a nice ide for beginners and experts alike.

    I would also recommend creating a second "Run..." configuration where instead of using the "Factory" class as your main executable, you use the "Simulator" class. (Keep the arguments string the same). That way, you can test your app in the simulator with one click, instead of having to start the factory and then launch the simulator from outside eclipse.
     
  4. TiVoPony

    TiVoPony New Member

    2,194
    0
    May 11, 2002
    Alviso,...
    Good idea, that's slick. :)

    You also have to add both hme.jar and simulator.jar when you're setting up your project.

    I'll add it in as an option above. Thanks for the suggestion!

    Pony
     
  5. TiVoPony

    TiVoPony New Member

    2,194
    0
    May 11, 2002
    Alviso,...
    You're welcome. :D

    Drop a post here when you get Hello World running.

    Pony
     
  6. trojanrabbit

    trojanrabbit Cat Referee

    3,337
    0
    Mar 10, 2001
    Near the...
    Thanks, Pony.

    Been a bad day for installing things, tried to install a printer on my old fileserver PC, the program ran once, said there wasn't enough disk space, and won't run again (there's plenty of space now), of course it's running WINME so I get what I deserve. Went to install all of the java stuff on this laptop and somehow I screwed up and deleted something I shouldn't have. That's what I get for using this laptop in bed.

    Think everything is installed now and happy so I'll try what's in your post.
     
  7. gman622

    gman622 New Member

    111
    0
    Feb 17, 2005
    you also easily fool around with all the samples included in the SDK by choosing File>Import>Existing Ant Buildfile
    (first change the pathelement of hme.jar) and browse to hme_sdk_ea1\samples\build.xml
     
  8. fisherk

    fisherk New Member

    27
    0
    Sep 4, 2004
    Cool I have been using Eclipse to build my Home Automation app but have been building then running every time. Now I run it right in the simulator from elcipse...
    Very nice - thanx!
     
  9. trojanrabbit

    trojanrabbit Cat Referee

    3,337
    0
    Mar 10, 2001
    Near the...
    Ah, success! Hello World appears on the Kitchen TiVo

    Time to try some of the other demos.

    Now if only I could do this on the Humax DVD..... j/k
     
  10. TiVoPony

    TiVoPony New Member

    2,194
    0
    May 11, 2002
    Alviso,...
    Congratulations! :)

    Feels good to get something running, doesn't it?

    HME is coming to the DVD platforms, we started with the standalones. Remember, for now it's really a developers-only kind of feature, it's not intended yet for the average consumer. Later this year you'll see it more front and center, and on more boxes.

    Cheers,
    Pony
     
  11. VaderFan

    VaderFan New Member

    5
    0
    Jan 30, 2005
    Thanks TivoPony for posting that walkthrough, certainly made things easy. Now I can put up provacative messages for my wife to check during commercials if I can keep her from pressing the skip button long enough.

    PonyPoker is pretty sweet too! :up:
     
  12. shady

    shady Previously European

    4,265
    1
    May 31, 2002
    Morgan...
    Thanks for the tutorial Pony. This got me up and running really quickly. I'm now playing with and looking through the samples.

    just need some inspiration now!!!
    :)
     
  13. N.Tx.Beginner

    N.Tx.Beginner New Member

    2
    0
    Feb 21, 2005
    Sorry if this should be obvious, but can you post and example showing how to change the pathelement of the hme.jar?
     
  14. gman622

    gman622 New Member

    111
    0
    Feb 17, 2005
    this is what i changed my build.xml to include:

    <property name="hme.jar" location="C:\TivoHME\hme_sdk_ea1\hme.jar"/>

    <pathelement path="${hme.jar}"/>


    of course you need to change "C:\TivoHME\hme_sdk_ea1\hme.jar" to wherever your hme.jar is located.

    btw you can also add the bananas samples to the hme samples.
    right click on TiVo HME Sample Applications:Import>File System, then browse to C:\TivoHME\bananas_ea1\sample\src Seclect All>Finish
    then you add bananas.jar to your Java Build Path-Libraries(Add External Jars...)
     
  15. jeffrey_ropp

    jeffrey_ropp New Member

    36
    0
    Dec 9, 2003
    TivoPony,

    First, thanks for a nice writeup to get us java newbies moving. I've played around with a similar writeup that allowed me to write HelloWorld using another IDE, NetBeans. Would you say this environments are similar or does eclipse offer something uniquely well suited to HME dev?

    More importantly, I'd love to see a sample project (or writeup - but preferably the former) that shows the way when using the bananas classes. I successfully got a project to run, but I'm not entirely sure how it worked nor could I walk someone thru it! Would you be up for another writeup with attachments?

    Many thanks,
    Jeff
     
  16. boscodegama

    boscodegama New Member

    137
    0
    Feb 21, 2005
    Thanks for the getting started in Eclipse. I had recently started checking it out prior to HME being released but hadn't done anything serious in it yet. I'm definitely excited by the opportunities.

    Anyway, I know enough about Java to be dangerous but don't know a lot of the methodology and practices. Anyone want to clue me in on how to create a Web Start JNLP from my project?



    thanks..
     
  17. jnk27

    jnk27 New Member

    35
    0
    Dec 21, 2001
    Massachusetts
    YeeHaa! It's alive.

    Thanks.
    John
     
  18. N.Tx.Beginner

    N.Tx.Beginner New Member

    2
    0
    Feb 21, 2005
  19. rrr22777

    rrr22777 New Member

    532
    0
    Jul 31, 2002
    Thank you TivoPony. I got HelloWorld to work. My motivation to do this was to change the default zip code in GoogleMap Plus!
     
  20. quell

    quell New Member

    5
    0
    Jul 24, 2002
    Thank You! Thank You! Thank You!


    Very usefull post.

    I was totally stuck trying to get this to run until I read your post.
    :)
     

Share This Page