Avatar of wasabi3689
wasabi3689
Flag 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.
JavaJava EEJava App Servers

Avatar of undefined
Last Comment
CPColin

8/22/2022 - Mon
CPColin

Don't add ".class" at the end of the class name and it should work a bit better.
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
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.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Sharon Seth

Why give the classpath when you are already in the dir where you have the class file?
girionis

Because the current dir is not included in the classpath by default.
CEHJ

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

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
girionis

I noticed that sometimes it is and sometimes it isn't. It can be included, just to be on the safe side.
CEHJ

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
wasabi3689

ASKER
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>
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
CPColin

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

wasabi3689

ASKER
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
CPColin

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
wasabi3689

ASKER
This is document file. Which link I should use to download?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
CPColin

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.
wasabi3689

ASKER
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?
CPColin

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
wasabi3689

ASKER
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.
CPColin

Please continue reading the PDF file past the part that says, "Download the Autoingestion.class file." It explains the parameters you need.
wasabi3689

ASKER
I downloaded it, but I don't use any username, password... I don't know how I come up the parameters required.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
CPColin

Why are you trying to run this application?
CEHJ

You'll make life a lot easier for yourself by prepending

C:\Program Files (x86)\Java\jre7\bin

to your PATH environment variable
wasabi3689

ASKER
I tried it, I added C:\Program Files (x86)\Java\jre7\bin to PATH environment variable. It mess ed up my other programs.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
CEHJ

Sounds like you did it wrong. Look at the documentation and examples
wasabi3689

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?
CPColin

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?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
wasabi3689

ASKER
not sure. I don't know the those values too. I am troubleshooting, not the application I developed
CPColin

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.