3 /* This file is part of the KDE project
5 * Copyright (C) 2000 Richard Moore <rich@kde.org>
6 * 2000 Wynn Wilkes <wynnw@caldera.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #ifndef KJAVAPROCESS_H
25 #define KJAVAPROCESS_H
30 * @short A class for invoking a Java VM
32 * This class is a general tool for invoking a Java interpreter. It allows you
33 * to specify some of the standard options that should be understood by all
36 * @author Richard J. Moore, rich@kde.org
37 * @author Wynn Wilkes, wynnw@calderasystems.com
40 class KJavaProcessPrivate
;
41 class KJavaProcess
: public KProcess
//QObject
47 * Creates a process object, the process is NOT invoked at this point.
48 * You should first set the process's parameters, and then call startJava.
50 KJavaProcess( QObject
*parent
= 0 );
51 virtual ~KJavaProcess();
54 * Invoke the JVM with the parameters that have been set. The Java process
55 * will start after this call.
60 * Stop the JVM (if it's running).
65 * Returns the status of the java Process- true if it's ok, false if it has died.
66 * It calls K3Process::isRunning()
71 * Used to specify the path to the Java executable to be run.
73 void setJVMPath( const QString
& path
);
76 * This will set the classpath the Java process will use. It's used as a the
77 * -cp command line option. It adds every jar file stored in $KDEDIRS/share/apps/kjava/
78 * to the classpath, and then adds the $CLASSPATH environmental variable. This allows
79 * users to simply drop the JSSE (Java Secure Sockets Extension classes into that directory
80 * without having to modify the jvm configuration files.
82 void setClasspath( const QString
& classpath
);
85 * Set a property on the java command line as -Dname=value, or -Dname if value is QString().
86 * For example, you could call setSystemProperty( "kjas.debug", "" ) to set the kjas.debug property.
88 void setSystemProperty( const QString
& name
, const QString
& value
);
91 * The class to be called when startJava() is called.
93 void setMainClass( const QString
& clazzName
);
96 * Extra flags passed to the JVM.
98 void setExtraArgs( const QString
& args
);
101 * Arguments passed to the main class. They will be very last in the java
102 * command line, after the main class.
104 void setClassArgs( const QString
& classArgs
);
107 * Sends a command to the KJAS Applet Server by building a QByteArray
108 * out of the data, and then writes it standard out.
110 void send( char cmd_code
, const QStringList
& args
);
113 * Sends a command to the KJAS Applet Server by building a QByteArray
114 * out of the data, and then writes it standard out. It adds each QString
115 * in the arg list, and then adds the data array.
117 void send( char cmd_code
, const QStringList
& args
, const QByteArray
& data
);
120 * Writes all pending data to JVM
126 * This slot is called when the Java Process writes to standard out. We then
127 * process the data from the file descriptor that is passed to us and send the
128 * command to the AppletServer
130 void slotReceivedData();
132 * This slot is called when the Java Process exited.
137 virtual bool invokeJVM();
138 virtual void killJVM();
140 QByteArray
addArgs( char cmd_code
, const QStringList
& args
);
141 void storeSize( QByteArray
* buff
);
144 void received( const QByteArray
& );
145 void exited( int status
);
148 KJavaProcessPrivate
* const d
;
152 #endif // KJAVAPROCESS_H