aspose file tools*
The moose likes Beginning Java and the fly likes Am I going the right way about this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Am I going the right way about this?" Watch "Am I going the right way about this?" New topic
Author

Am I going the right way about this?

Daniel Eather
Greenhorn

Joined: Jul 29, 2009
Posts: 4
Hi all,

Another newbie here I'm slowly making the change from VB orientated scripting (VB6, vbs, vba, etc) to Java. I'm trying to achieve something, and I'm not sure I'm going the right way about it.

I've built an IR blaster and trapped the signals I need, to turn my air con ON and OFF. I can call these signals from a batch file (eg. "irblast.exe ac_on.IR"). This works fine. What i've done next is write some PHP code to save a file to my webserver when I log on to my website and submit the text "ac=on", from a regular html form. The result is a file on my webserver called aircon.status, containing the word "ON". I've then written some JAVA code to check the file exists, read the file and run the batch file ac_on.bat or ac_off.bat (depending on whether the file contains the word ON or OFF). This all works fine, but now I'd like the Java code to run as a service, so it's always running and continues to check the existance of the aircon file. I'm currently looking at YAJSW http://yajsw.sourceforge.net/. I havn't finished configuring it all yet, but....am i approaching this logically the right way? Is there an easier way to have a java program run, checking every 5 minutes or so the existance of an online file and running a batch file based on what's contained in the file?

I'd appreciate ANY guidance at all. I'm really new to the world of Java, and knowing me I'm going the long way around something that is probably very simple to achieve.

Many Thanks,
Dan

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38353
    
  23
Welcome to JavaRanch

I only read the first few words of your post and though, "no you aren't."

Start small. Even things like "for" loops in Java are slightly different from other languages, so you can hide some dangerous misconceptions from yourself by starting with a big project. Beware of batch files and services. They tie the code to a particular platform (in that case Windows).

At least that's my opinion
Daniel Eather
Greenhorn

Joined: Jul 29, 2009
Posts: 4
Hi,

Thanks for the reply. I've been working through a bunch of lessons. Getting familiar with all the basic. So far so good. Although it is a pretty big learning curve . I've managed to use the wrapper to create the service. However I can't seem to start the service. I might post a new thread in the applicable section of the forums.

Many Thanks,
Dan

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

It'd be easiest to redo the web service in Java as a servlet (using Tomcat, for example) and then include a scheduled job in the servlet container which did the checking and signaling. Actually, it'd be easiest to have the servlet directly kick off the IR signal, but perhaps that's too open to abuse.


[Jess in Action][AskingGoodQuestions]
Daniel Eather
Greenhorn

Joined: Jul 29, 2009
Posts: 4
Hi,

Well I've done some reading RE servlets and this would have been perfect! Unfortunately I had to pay for external web hosting as my ISP doesn't allow inbound port 80, and we block all but inbound port 80 at work. Rendering my web server's configuration (on another random port) useless. I will definitely be looking into servlets though for possible future use (perhaps when I shift to a more reasonable ISP).

Thanks for your suggestions.
Dan
Daniel Eather
Greenhorn

Joined: Jul 29, 2009
Posts: 4
Hi,

Just to let anyone interested know, I got the service to start using yajsw. I had to manually configure the account (and password) to run the service under. For some reason the configuration file didn't apply correctly. Everything's working nicely now.

Cheers,
Dan
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38353
    
  23
Well done, getting it to work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Am I going the right way about this?