Link to home
Start Free TrialLog in
Avatar of wasabi3689
wasabi3689Flag for United States of America

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.
Avatar of CPColin
CPColin
Flag of United States of America image

Don't add ".class" at the end of the class name and it should work a bit better.
Avatar of wasabi3689

ASKER

still the same message after I remove .class

C:\Program Files (x86)\Java\jre7\bin>java.exe -cp . xxxxx
Error: Could not find or load main class xxxxx
Avatar of girionis
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.
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

Open in new window

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
Here is what I got when I type

dir *.class

C:\sharein\AppleAppStoreScript>dir *.class
 Volume in drive C has no label.
 Volume Serial Number is 0CB0-24E7

 Directory of C:\sharein\AppleAppStoreScript

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\AppleAppStoreScript>C:\Program Files (x86)\Java\jre7\bin\java.exe -cp
 . Autoingestion
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

C:\sharein\AppleAppStoreScript>


Here is what I got when I type

C:\sharein\AppleAppStoreScript>C:\Program Files (x86)\Java\jre7\bin\java.exe -cp
 . Autoingestion.class
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

C:\sharein\AppleAppStoreScript>
Try putting the command in quotation marks, like this:

C:\sharein\AppleAppStoreScript>"C:\Program Files (x86)\Java\jre7\bin\java.exe" -cp . Autoingestion

Open in new window

I try this,

C:\sharein\AppleAppStoreScript>"C:\Program Files (x86)\Java\jre7\bin\java.exe" -
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\AppleAppStoreScript>"C:\Program Files (x86)\Java\jre7\bin\java.exe" -
cp . Autoingestion.class
Error: Could not find or load main class Autoingestion.class

C:\sharein\AppleAppStoreScript>
ASKER CERTIFIED SOLUTION
Avatar of CPColin
CPColin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
I downloaded the file "Autoingestion.class", located in the download folder. Do I need to copy this file Autoingestion.class to C:\sharein\AppleAppStoreScript>   ? then run the command again?
I try this,

C:\sharein\AppleAppStoreScript>"C:\Program Files (x86)\Java\jre7\bin\java.exe" -
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.
I copied and pasted the download one to replace the old one in C:\sharein\AppleAppStoreScript>

I got the same error.

C:\sharein\AppleAppStoreScript>"C:\Program Files (x86)\Java\jre7\bin\java.exe" -
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.
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
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
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 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?
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.