Joined
·
765 Posts
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+
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+