Could not find the main class:

Rol

Aktives Mitglied
Hallo,

ich möchte folgendes Java Programm zum laufen bringen:
IBController | Download IBController software for free at SourceForge.net

Ich starte das Programm wie in der readme.txt angegeben in der Kommandozeile mit:

Code:
java.exe -cp  C:\Jts\ IBController.jar ibcontroller.IBController

"C:\Jts" ist dabei ein Pfad zu einem anderen Javaprogram welches später von diesem gestertet werden soll.

Dann erhalte ich folgende Fehlermeldung:

Code:
C:\IBControllerV2-8-4-1>java.exe -cp  C:\Jts\ IBController.jar ibcontroller.IBCo
ntroller
Exception in thread "main" java.lang.NoClassDefFoundError: IBController/jar
Caused by: java.lang.ClassNotFoundException: IBController.jar
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: IBController.jar.  Program will exit.

Ich kann mir nicht vorstellen, dass es am Programm selbt liegt. Es läuft auf anderen Rechnern (angeblich) problemmlos. Ich vermute vielmehr, dass auf meinem Rechner irgendetwas mit den Pfaden falsch ist.

"Set" in der cmd bringt mir:

Code:
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Rol\AppData\Roaming
asl.log=Destination=file
CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=BUERO
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Rol
IBCDIR=C:\IBController
IBCINI=C:\IBController\ibcontroller.ini
JAVAOPTS=-Dsun.java2d.noddraw=true -Xmx512M
LOCALAPPDATA=C:\Users\Rol\AppData\Local
LOGONSERVER=\\BUERO
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program F
iles (x86)\Java\jdk1.6.0_21\bin;C:\Program Files (x86)\Java\jre1.6.0_20\bin;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=AMD64 Family 15 Model 107 Stepping 2, AuthenticAMD
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=6b02
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
QTJAVA=C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\Rol\AppData\Local\Temp
TMP=C:\Users\Rol\AppData\Local\Temp
TWSCP=jts.jar;pluginsupport.jar;hsqldb.jar;jcommon-1.0.12.jar;jfreechart-1.0.9.j
ar;jhall.jar;other.jar;rss.jar;riskfeed.jar
TWSDIR=C:\Jts\
TWSPASSWORD=paula11
TWSUSERID=jensn756
USERDOMAIN=Buero
USERNAME=Rol
USERPROFILE=C:\Users\Rol
VBOX_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
windir=C:\Windows

MfG
Rol
 
Code:
java.exe -cp C:\Jts\ IBController.jar ibcontroller.IBController

Ist das Leerzeichen zwischen C:\Jts\ und OBController.jar nur hier im Forum oder auch von dir?
 
Hallo mvitz,

ich weiß jetzt gar nicht mehr wie die "Urvariante" war, aber egal ob mit oder ohne Leerzeichen, es kommt derselbe Fehler.
 
Reicht es nicht, wenn man nur
Code:
java -cp C:\Jts\ ...
eingibt? Also halt ohne ".exe"?

Interessant wäre mal zu wissen, in welchem Ordner Du die IBController.jar versuchst auszuführen. Denn wenn du in der cmd im Ordner C:\ bist und die JAR unter C:\Programme\Was-weiß-ich\ liegt, kommst Du mit diesem Command nicht weit...
 
So hab mir mal selbst die Datei heruntergeladen und und dann das jar Archiv in den Ordner C:\test kopiert. danach die CMD geöffnet und folgende befehle eingegeben

Code:
cd C:\Test
java -cp IBController.jar ibcontroller.IBController

und das programm hat sich gestartet.
 
Nur "C:\Jts" soll in den Classpath, "IBController.jar" ist das jar welches ich starten möchte und "ibcontroller.IBController" soll (wohl?) die Main bezeichnen.

Hier ein auszug aus der mitgelieferten readme.txt



The command for running IBController has the following basic form:

java -cp <classpath> <otherOptions> <entryPoint> [<config file>|NULL] [<loginId> <password>]

where

<classpath>
tells the Java virtual machine where to look to find
the class files that must be loaded in order to run both
IBController and TWS. You must ensure that all the information
from the corresponding item in the command to run TWS without
IBController is included, PLUS the path and name of the
IBController.jar file. Note that this information may vary
in different releases of TWS.

To find this information on Windows, locate the entry to start
TWS in your start menu (usually Start > All Programs > Trader
Workstation 4.0 > Trader Workstation 4.0). Right click on this
entry and select Properties from the pop-up menu. The command
is in the field labelled 'Target'.

Note that the classpath in the TWS shortcut assumes that the
TWS files are in the same folder as the shortcut. If your
command file runs in a different folder (for example the folder
where the IBController files are stored) you will need to:

EITHER make sure each classpath item is prefixed with the path
to the TWS files folder

OR your command file can change directory to the TWS files
folder before issuing the java command (this is what
the sampleIBControllerStart.bat file does)

<otherOptions>
these are items which modify the behaviour of the
Java VM. Examples that are used by TWS include:

-Dsun.java2d.noddraw=true
-Xmx512M

Any such options that appear in the command to start TWS should
also be included in the command to start IBController.

<entryPoint>
indicates whether to start TWS or the IB Gateway. Must be one
of the following values (note that these are case-sensitive):

ibcontroller.IBController (to start TWS)
ibcontroller.IBGatewayController (to start IB Gateway)

<config file>
is the path and name of the configuration file.
If this is not supplied or has the value NULL, then
IBController will look for a file called
IBController.<username>.ini in the working directory,
where <username> is your username on your computer
(NOT your IB account username).

<loginId>
is your TWS login id.

<password>
is your TWS password.

Note that if you don't supply <loginId> and <password> in the command
then they must be in the configuration file as described in 3.3.

Unix example for TWS 865, using a configuration file called demo.ini:

$ cd opt/IBJts
$ java -server -cp jcommon-1.0.0.jar😛luginsupport.jar:jfreechart-1.0.0.jar:jhall.jar:\
> jts.jar😱ther.jar:rss.jar:/opt/IBController.jar \
> ibcontroller.IBController /opt/IBController/demo.ini
 
Falls es noch nicht kam, probieres es auch mal so:
Code:
java -cp .;C:\Jts\IBController.jar ibcontroller.IBController

oder so:

Code:
java -jar .;C:\Jts\IBController.jar
 
Nur "C:\Jts" soll in den Classpath

Tschuldigung das ich das sage aber das ist ein Blödsinn. natürlich muss IBController.jar in den Classpath vl, muss für dein Programm auch der Ordner C:\Jts in den CP, aber um das jar archiv das in der dem zip liegt das man downloaden kann, muss nur das Archiv in den cp steht übrigens sogar genau so wie ich es in meinem Post geschrieben habe in der readme
 
Code:
java -cp C:\Cts;IBController.jar ibcontroller.IBController

Dann fliegt mir das hier um die Ohren:


Code:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. Alle Rechte vorbehalten.

C:\Users\Steffen>cd ..

C:\Users>cd ..

C:\>cd IBControllerV2-8-4-1

C:\IBControllerV2-8-4-1>test

C:\IBControllerV2-8-4-1>java -cp C:\Cts;IBController.jar ibcontroller.IBControll
er
System Properties
------------------------------------------------------------
java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = C:\Program Files (x86)\Java\jdk1.6.0_21\jre\bin
java.vm.version = 17.0-b16
java.vm.vendor = Sun Microsystems Inc.
java.vendor.url = [url=http://java.sun.com/]Oracle Technology Network for Java Developers[/url]
path.separator = ;
java.vm.name = Java HotSpot(TM) Client VM
file.encoding.pkg = sun.io
sun.java.launcher = SUN_STANDARD
user.country = DE
sun.os.patch.level =
java.vm.specification.name = Java Virtual Machine Specification
user.dir = C:\IBControllerV2-8-4-1
java.runtime.version = 1.6.0_21-b06
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs = C:\Program Files (x86)\Java\jdk1.6.0_21\jre\lib\endorsed
os.arch = x86
java.io.tmpdir = C:\Users\Steffen\AppData\Local\Temp\
line.separator =

java.vm.specification.vendor = Sun Microsystems Inc.
user.variant =
os.name = Windows 7
sun.jnu.encoding = Cp1252
java.library.path = C:\Program Files (x86)\Java\jdk1.6.0_21\bin;.;C:\Windows\Sun
\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windo
ws\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x
86)\QuickTime\QTSystem\;C:\Program Files (x86)\Java\jdk1.6.0_21\bin;C:\Program F
iles (x86)\Java\jre1.6.0_20\bin;
java.specification.name = Java Platform API Specification
java.class.version = 50.0
sun.management.compiler = HotSpot Client Compiler
os.version = 6.1
user.home = C:\Users\Steffen
user.timezone =
java.awt.printerjob = sun.awt.windows.WPrinterJob
file.encoding = Cp1252
java.specification.version = 1.6
java.class.path = C:\Cts;IBController.jar
user.name = Steffen
java.vm.specification.version = 1.0
java.home = C:\Program Files (x86)\Java\jdk1.6.0_21\jre
sun.arch.data.model = 32
user.language = de
java.specification.vendor = Sun Microsystems Inc.
awt.toolkit = sun.awt.windows.WToolkit
java.vm.info = mixed mode, sharing
java.version = 1.6.0_21
java.ext.dirs = C:\Program Files (x86)\Java\jdk1.6.0_21\jre\lib\ext;C:\Windows\S
un\Java\lib\ext
sun.boot.class.path = C:\Program Files (x86)\Java\jdk1.6.0_21\jre\lib\resources.
jar;C:\Program Files (x86)\Java\jdk1.6.0_21\jre\lib\rt.jar;C:\Program Files (x86
)\Java\jdk1.6.0_21\jre\lib\sunrsasign.jar;C:\Program Files (x86)\Java\jdk1.6.0_2
1\jre\lib\jsse.jar;C:\Program Files (x86)\Java\jdk1.6.0_21\jre\lib\jce.jar;C:\Pr
ogram Files (x86)\Java\jdk1.6.0_21\jre\lib\charsets.jar;C:\Program Files (x86)\J
ava\jdk1.6.0_21\jre\classes
java.vendor = Sun Microsystems Inc.
file.separator = \
java.vendor.url.bug = [url=http://java.sun.com/cgi-bin/bugreport.cgi]Report a Bug or Request a Feature[/url]
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
sun.desktop = windows
sun.cpu.isalist =
------------------------------------------------------------
16:10:00:853 IBController: ini file is C:\IBControllerV2-8-4-1\IBController.stef
fen.ini
16:10:00:866 IBController: IBControllerServer is started.
16:10:00:886 IBController: IBControllerServer listening on address: Buero/192.16
8.11.3 port: 7462
Exception in thread "main" java.lang.NoClassDefFoundError: jclient/LoginFrame
        at ibcontroller.IBController.startTws(IBController.java:395)
        at ibcontroller.IBController.startTwsOrGateway(IBController.java:402)
        at ibcontroller.IBController.load(IBController.java:167)
        at ibcontroller.IBController.main(IBController.java:147)
Caused by: java.lang.ClassNotFoundException: jclient.LoginFrame
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 4 more
 
Da fliegt dir nichts um die Ohren, sondern das ist die Ausgabe des Programms

und der fehler unten kommt wohl von einer fehlerhaften ini file keine Ahnung was das ist, da ich das Programm nicht kenne
 

Zurück
Oben