|
From: Leif M. <le...@ta...> - 2006-03-09 00:35:27
|
Cyrene,
Yes the wrapper can do that. See this page:
http://wrapper.tanukisoftware.org/doc/english/launch-win.html#service
Cheers,
Leif
Cyrene Law wrote:
> Leif,
>
> thanks,problem is fixed when i change my class to public class. Any
> solution to make this service auto start when computer start?
>
>
> Regards.
> cyrene
>
> On 3/8/06, *Leif Mortenson* <le...@ta...
> <mailto:le...@ta...>> wrote:
>
> Cyrene,
> Your main method is correct, but the testfile class is not public.
> Change
> class testfile {
> to
> public class testfile{
>
> I was able to reproduce this with a class in the root package
> as you
> are doing, but
> it appears to work fine as a public class even if the public token is
> omitted when the
> class is located in a package... That seems wrong.
> If I attempt to run the class from java directly then it works in
> both cases... Anyone
> know about any documentation where this is described.
>
> Cheers,
> Leif
>
> Cyrene Law wrote:
> > Hi Leif,
> >
> > Thanks for your reply.Below is my testfile.java.I jar up the
> testfile
> > and try to learn use Java Service Wrapper.
> >
> > ======================================
> > import java.util.*;
> > import java.io.*;
> >
> >
> > class testfile{
> > public static void main(String args[]){
> > System.out.println("testing test file");
> > Calendar cal = new GregorianCalendar();
> >
> > // Get the components of the date
> > int era = cal.get(Calendar.ERA); // 0=BC, 1=AD
> > int year = cal.get(Calendar.YEAR); // 2002
> > int month = cal.get(Calendar.MONTH); // 0=Jan,
> 1=Feb, ...
> > int day = cal.get(Calendar.DAY_OF_MONTH); // 1...
> > int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // 1=Sunday,
> 2=Monday,
> >
> > try {
> > File file = new File("cyrene.txt");
> >
> > // Create file if it does not exist
> > boolean success = file.createNewFile();
> > if (success) {
> > // File did not exist and was created
> > int hour12 = cal.get(Calendar.HOUR); // 0..11
> > int hour24 = cal.get( Calendar.HOUR_OF_DAY); // 0..23
> > int min = cal.get(Calendar.MINUTE); // 0..59
> > int sec = cal.get(Calendar.SECOND); // 0..59
> > int ms = cal.get(Calendar.MILLISECOND ); // 0..999
> > int ampm = cal.get(Calendar.AM_PM); // 0=AM, 1=PM
> > String ts=Integer.toString(day)+"/"+Integer.toString(month)+
> > "/"+Integer.toString(year)+" "+Integer.toString(hour12)+
> > ":"+Integer.toString(min)+":"+Integer.toString(sec);
> > Writer output = null;
> > try {
> > //use buffering
> > //FileWriter always assumes default encoding is OK!
> > output = new BufferedWriter( new FileWriter(file) );
> > output.write( ts );
> > }
> > finally {
> > //flush and close both "output" and its underlying FileWriter
> > if (output != null) output.close();
> > }
> > } else {
> > // File already exists
> > }
> > } catch (IOException e) {
> > }
> >
> >
> >
> >
> > }
> > }
> > ======================================
> >
> > I don't know how to use Method 3.So i use method 1.I
> successfully use
> > Method 1 in Windows XP.I really got problem use wrapper in RHEL 4.
> > Here i also enclose my wrapper.zip as your reference about my
> setting.
> >
> > Yours sincerely,
> > Cyrene
> >
> >
> >
> >
> >
> >
> > On 3/8/06, *Leif Mortenson* < le...@ta...
> <mailto:le...@ta...>
> > <mailto:le...@ta...
> <mailto:le...@ta...>>> wrote:
> >
> > Cyrene,
> > It looks like you are setting everything up on the
> Wrapper side
> > correctly. But
> > I am guessing that the problem is with your testfile
> class. Does
> > it have a
> > public static main method? The error is saying that the
> class is
> > found
> > and loaded
> > but that the main method could not be found.
> >
> > Cheers,
> > Leif
> >
> > Cyrene Law wrote:
> > > i downloaded the wrapper_linux_3.1.2, i create a jar file
> named
> > > testfile.jar and put it into 'lib' folder which contain
> wrapper.jar
> > > and libwrapper.so.I also make the testfile.jar as execute
> (chmod +x)
> > >
> > > Then i copy the sh.script.in <http://sh.script.in>
> <http://sh.script.in>
> > <http://sh.script.in <http://sh.script.in
> <http://sh.script.in>>> into the 'bin'
> > > folder, and named it as 'testfile' and chmod +x for
> 'testfile'.I
> > only
> > > edit the
> > > APP_Name="testfile"
> > > APP_LONG_NAME="my testfile"
> > >
> > > Then i copy the ' wrapper.conf.in <http://wrapper.conf.in>
> <http://wrapper.conf.in>
> > < http://wrapper.conf.in>' to 'conf'
> > > folder and rename it as.I add:
> > > wrapper.java.classpath.2=../lib/testfile.jar
> > > wrapper.app.parameter=testfile
> > >
> > > (because my main file is testfile.class)
> > >
> > > After that,i try to run it:
> > > ./testfile console
> > >
> > > it displays error:
> > > WrapperSimpleApp:Encountered an error running main:
> > > java.lang.IlegalAccessException: class
> > > org.tanukisoftware.wrapper.wrapperSimleApp cannot access a
> member of
> > > class testfile with modifier 'public static'
> > >
> > > if i edit the 'wrapper.conf ' as below:
> > > wrapper.java.mainclass=org.tanukisoftware.wrapper.test.main
> > >
> > > it displays error:
> > > Exception in thread 'main' java
> > >
> .lang.NoClassDefFoundError:org/tanukisoftware/wrapper/test/main
> > >
> > >
> > > What steps are wrong during the process?
> > >
> > > Can you send me a detail guide and example using java service
> > > wrapper?Urgently wanted.My email is cyr...@gm...
> <mailto:cyr...@gm...>
> > <mailto:cyr...@gm... <mailto:cyr...@gm...>>
> > > <mailto: cyr...@gm...
> <mailto:cyr...@gm...> <mailto:cyr...@gm...
> <mailto:cyr...@gm...>>>
> > >
> > > Thank you in advanced.
> > >
> > >
> >
> >
>
>
|