wasabi3689
asked on
Java error
I have a java program called "xxx.class" on a Windows machine. It's located in C:\Products\XXXScript
If I am in that directory and type this:
"C:\Program Files (x86)"\Java\jre7\bin\java. exe
I get the help for java, so that executable is being seen
If I do this:
"C:\Program Files (x86)"\Java\jre7\bin\java. exe -cp . xxx.class
I get "Error: Could not find or load main class xxx.class" even though xxx.class is in my current directory and I've set classpath to ".". I can remove the -cp option, change it to -classpath, set it to the full path to the current directory, doesn't matter.
Anyone can help me trouble shoot.
If I am in that directory and type this:
"C:\Program Files (x86)"\Java\jre7\bin\java.
I get the help for java, so that executable is being seen
If I do this:
"C:\Program Files (x86)"\Java\jre7\bin\java.
I get "Error: Could not find or load main class xxx.class" even though xxx.class is in my current directory and I've set classpath to ".". I can remove the -cp option, change it to -classpath, set it to the full path to the current directory, doesn't matter.
Anyone can help me trouble shoot.
Don't add ".class" at the end of the class name and it should work a bit better.
ASKER
still the same message after I remove .class
C:\Program Files (x86)\Java\jre7\bin>java.e xe -cp . xxxxx
Error: Could not find or load main class xxxxx
C:\Program Files (x86)\Java\jre7\bin>java.e
Error: Could not find or load main class xxxxx
Assuming you are in C:\Products\XXXScript, try
"C:\Program Files (x86)"\Java\jre7\bin\java -cp . xxx
Also make sure that you class is not in a package, otherwise you will need to use the fully qualified class name.
"C:\Program Files (x86)"\Java\jre7\bin\java -cp . xxx
Also make sure that you class is not in a package, otherwise you will need to use the fully qualified class name.
Why give the classpath when you are already in the dir where you have the class file?
Because the current dir is not included in the classpath by default.
Because the current dir is not included in the classpath by default.It usually is on Windows actually (at least it used to be)
Please post output of
dir *.class
I noticed that sometimes it is and sometimes it isn't. It can be included, just to be on the safe side.
It can be included, just to be on the safe side.Yes, i was just trying to edit my comment as you were posting. It was meant to say that there is a good reason for using -cp . explicitly - that it eliminates problems that can be caused from having set an incorrect static classpath
ASKER
Here is what I got when I type
dir *.class
C:\sharein\AppleAppStoreSc ript>dir *.class
Volume in drive C has no label.
Volume Serial Number is 0CB0-24E7
Directory of C:\sharein\AppleAppStoreSc ript
02/10/2012 10:47 AM 3,481 Autoingestion.class
1 File(s) 3,481 bytes
0 Dir(s) 237,855,657,984 bytes free
Here is what I got when I type
C:\sharein\AppleAppStoreSc ript>C:\Pr ogram Files (x86)\Java\jre7\bin\java.e xe -cp
. Autoingestion
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
C:\sharein\AppleAppStoreSc ript>
Here is what I got when I type
C:\sharein\AppleAppStoreSc ript>C:\Pr ogram Files (x86)\Java\jre7\bin\java.e xe -cp
. Autoingestion.class
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
C:\sharein\AppleAppStoreSc ript>
dir *.class
C:\sharein\AppleAppStoreSc
Volume in drive C has no label.
Volume Serial Number is 0CB0-24E7
Directory of C:\sharein\AppleAppStoreSc
02/10/2012 10:47 AM 3,481 Autoingestion.class
1 File(s) 3,481 bytes
0 Dir(s) 237,855,657,984 bytes free
Here is what I got when I type
C:\sharein\AppleAppStoreSc
. Autoingestion
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
C:\sharein\AppleAppStoreSc
Here is what I got when I type
C:\sharein\AppleAppStoreSc
. Autoingestion.class
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
C:\sharein\AppleAppStoreSc
Try putting the command in quotation marks, like this:
C:\sharein\AppleAppStoreScript>"C:\Program Files (x86)\Java\jre7\bin\java.exe" -cp . Autoingestion
ASKER
I try this,
C:\sharein\AppleAppStoreSc ript>"C:\P rogram Files (x86)\Java\jre7\bin\java.e xe" -
cp . Autoingestion
Please enter all the required parameters. For help, please download the latest
User Guide from the Sales and Trends module in iTunes Connect.
C:\sharein\AppleAppStoreSc ript>"C:\P rogram Files (x86)\Java\jre7\bin\java.e xe" -
cp . Autoingestion.class
Error: Could not find or load main class Autoingestion.class
C:\sharein\AppleAppStoreSc ript>
C:\sharein\AppleAppStoreSc
cp . Autoingestion
Please enter all the required parameters. For help, please download the latest
User Guide from the Sales and Trends module in iTunes Connect.
C:\sharein\AppleAppStoreSc
cp . Autoingestion.class
Error: Could not find or load main class Autoingestion.class
C:\sharein\AppleAppStoreSc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is document file. Which link I should use to download?
I'm not sure what you mean. Either left-click it and let your browser handle it (the latest version of Firefox will open it for you) or right-click it, save it, and open it in your favorite program that can read PDF files. The instructions for what parameters you need to pass are in that file, in the "Auto-Ingest Tool" section.
ASKER
I downloaded the file "Autoingestion.class", located in the download folder. Do I need to copy this file Autoingestion.class to C:\sharein\AppleAppStoreSc ript> ? then run the command again?
I try this,
C:\sharein\AppleAppStoreScript>"C:\P rogram Files (x86)\Java\jre7\bin\java.e xe" -
cp . Autoingestion
Please enter all the required parameters. For help, please download the latest
User Guide from the Sales and Trends module in iTunes Connect.
The message this command gave you indicates that you already have the necessary class file. It ran and told you that you did not have the correct parameters. You now have to read the PDF file I linked above to determine which parameters you have to pass.
ASKER
I copied and pasted the download one to replace the old one in C:\sharein\AppleAppStoreSc ript>
I got the same error.
C:\sharein\AppleAppStoreSc ript>"C:\P rogram Files (x86)\Java\jre7\bin\java.e xe" -
cp . Autoingestion
Please enter all the required parameters. For help, please download the latest
User Guide from the Sales and Trends module in iTunes Connect.
I got the same error.
C:\sharein\AppleAppStoreSc
cp . Autoingestion
Please enter all the required parameters. For help, please download the latest
User Guide from the Sales and Trends module in iTunes Connect.
Please continue reading the PDF file past the part that says, "Download the Autoingestion.class file." It explains the parameters you need.
ASKER
I downloaded it, but I don't use any username, password... I don't know how I come up the parameters required.
Why are you trying to run this application?
You'll make life a lot easier for yourself by prepending
C:\Program Files (x86)\Java\jre7\bin
to your PATH environment variable
C:\Program Files (x86)\Java\jre7\bin
to your PATH environment variable
ASKER
I tried it, I added C:\Program Files (x86)\Java\jre7\bin to PATH environment variable. It mess ed up my other programs.
Sounds like you did it wrong. Look at the documentation and examples
ASKER
Here is the example from document
You must insert your own values.
java Autoingestion <username> <password> <vendorid> <report_type>
<date_type> <report_subtype> <date_yyyymmdd>
What did I do wrong?
You must insert your own values.
java Autoingestion <username> <password> <vendorid> <report_type>
<date_type> <report_subtype> <date_yyyymmdd>
What did I do wrong?
You did nothing wrong, but now you need to figure out what the right values are. I don't know your username, password, vendor ID, etc., so I can't help you find those values. Are you sure this specific application is appropriate for whatever you're trying to do?
ASKER
not sure. I don't know the those values too. I am troubleshooting, not the application I developed
I'm not sure I can really help you with this problem any further. The application is running now. You'll have to get those parameters from whomever it is you're troubleshooting for.