JavaStartup.st
author Stefan Vogel <sv@exept.de>
Tue, 08 Nov 2005 17:49:17 +0100
changeset 2121 7b06266d8249
parent 749 e898eaeff091
child 2152 1cbdfbcc685c
permissions -rw-r--r--
/tmp/cvsyRpZ5v

"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 Parts of the code written by Claus Gittinger are under following
 license:

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.

 Parts of the code written at SWING Reasearch Group [1] are MIT licensed:

 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the 'Software'), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:

 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.

 [1] Code written at SWING Research Group contain a signature
     of one of the above copright owners.
"
"{ Package: 'stx:libjava' }"

StandaloneStartup subclass:#JavaStartup
	instanceVariableNames:''
	classVariableNames:'ClassPath'
	poolDictionaries:''
	category:'Languages-Java-Support'
!

!JavaStartup class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 Parts of the code written by Claus Gittinger are under following
 license:

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.

 Parts of the code written at SWING Reasearch Group [1] are MIT licensed:

 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the 'Software'), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:

 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.

 [1] Code written at SWING Research Group contain a signature
     of one of the above copright owners.

"
! !

!JavaStartup class methodsFor:'constants & defaults'!

applicationRegistryPath
    "the key under which this application stores its process ID in the registry
     as a collection of path-components.
     i.e. if #('foo' 'bar' 'baz') is returned here, the current applications ID will be stored
     in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID.
     (would also be used as a relative path for a temporary lock file under unix).
     Used to detect if another instance of this application is already running."
    
    ^ #('stx' 'java_x')

    "Created: / 07-02-2011 / 10:55:08 / Marcel Hlopko <hlopik@gmail.com>"
!

applicationUUID
    "answer an application-specific unique uuid.
     This is used as the name of some exclusive OS-resource, which is used to find out,
     if another instance of this application is already running.
     Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used."
    
    ^ 'ST_X_JAVA_X'.

    "Created: / 07-02-2011 / 10:52:50 / Marcel Hlopko <hlopik@gmail.com>"
! !

!JavaStartup class methodsFor:'startup'!

main:argv 
    "Currently only -c option for classpath setting working"
    
    |class arguments classAndArguments classpath classpathFromEnv|

    classpath := OrderedCollection new.
    classpathFromEnv := OperatingSystem getEnvironment:#CLASSPATH.
    classpathFromEnv isNil ifFalse:[
        (classpathFromEnv asArrayOfSubstringsSeparatedBy:$:) do:[:each | 
            classpath add:each
        ]
    ].
    classAndArguments := OrderedCollection new.
    (GetOpt new)
        at:$c
            put:[:opt :arg | (arg asArrayOfSubstringsSeparatedBy:$:) do: [:each | classpath add: each]];
        at:$? 
            put:[:arg | self error:'not yet implemented'];
        default:[:arg | classAndArguments add:arg];
        parse:argv.
    class := classAndArguments at:1.
    arguments := classAndArguments
                removeFirst;
                yourself.
    Java flushAllJavaResources.
    self breakPoint:#mh.
    Java initialize.
    JavaVM initializeVM.
    classpath do:[:each | 
        Java addToClassPath:each
    ].
    (Java classForName:class) main:arguments asArray.

    "Created: / 07-02-2011 / 10:55:41 / Marcel Hlopko <hlopik@gmail.com>"
    "Modified: / 08-02-2011 / 00:55:42 / Marcel Hlopko <hlopik@gmail.com>"
    "Modified (format): / 19-08-2011 / 01:55:24 / cg"
! !

!JavaStartup class methodsFor:'documentation'!

version
    ^ '$Id$'
!

version_CVS
    ^ '§Header: /cvs/stx/stx/libjava/JavaStartup.st,v 1.2 2011/08/19 08:48:04 cg Exp §'
!

version_SVN
    ^ '$Id$'
! !