• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to run .class file?  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to complete a somewhat simple project, but am completely ignorant to programming and what not. I've been sitting here for the past two hours trying to download different programs from java, etc. I just need to know to to do this http://web.eecs.utk.edu/~mclennan/Classes/420/projects/project1/ca.html

So how can I get to the point where I can do this "To run the program, type the following at the command line:

java CASimulator X
where X is the number of experiments to run.
 
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

A link at the top of the page you cited allows you to download the executable .class file. you should probably right click on that link and select "Save as file..." or whatever context menu option you see that allows you to save whatever the link points to as a file in your local system. Then you'd open a terminal window and cd to the directory where you saved the .class file. Then you can issue that command to run the program. And don't take the instructions too literally; You have to give an actual number instead of "X" when you type in that command.
 
Daniel Harbsmeier
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:Welcome to the Ranch!

A link at the top of the page you cited allows you to download the executable .class file. You should probably right click on that link and select "Save as file..." or whatever context menu option you see that allows you to save whatever the link points to as a file in your local system. Then you'd open a terminal window and cd to the directory where you saved the .class file. Then you can issue that command to run the program. And don't take the instructions too literally; You have to give an actual number instead of "X" when you type in that command.


Hey! Thanks so much for your reply. I'm still a bit confused on the terminal window and cd part as I'm extremely ignorant to all of this. I'm on windows 7, and I've saved the .class file to my documents. If you don't mind, could I kinda get a play by play what to do next? I'm not sure what "cd" means, and I assume that Terminal window means my command prompt? Thanks in advance for your help.
 
Daniel Harbsmeier
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Harbsmeier wrote:
Junilu Lacar wrote:Welcome to the Ranch!

A link at the top of the page you cited allows you to download the executable .class file. You should probably right click on that link and select "Save as file..." or whatever context menu option you see that allows you to save whatever the link points to as a file in your local system. Then you'd open a terminal window and cd to the directory where you saved the .class file. Then you can issue that command to run the program. And don't take the instructions too literally; You have to give an actual number instead of "X" when you type in that command.


Hey! Thanks so much for your reply. I'm still a bit confused on the terminal window and cd part as I'm extremely ignorant to all of this. I'm on windows 7, and I've saved the .class file to my documents. If you don't mind, could I kinda get a play by play what to do next? I'm not sure what "cd" means, and I assume that Terminal window means my command prompt? Thanks in advance for your help.


So I've gotten to the point where when I type C:\Users\Daniel\Documents>CASimulator.class It tells me that java installation not completed, even though I've updated to the most recent java.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the command prompt is displayed in what's usually called a terminal window.

The cd command stands for "change directory" - you would type the command cd C:\Users\Daniel\Documents to change to the directory where you save the .class file. Then just follow the instructions that page gave.

You can check if you have properly installed Java by typing the command java -version - if you get no errors then you should be good.
 
Daniel Harbsmeier
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:Yes, the command prompt is displayed in what's usually called a terminal window.

The cd command stands for "change directory" - you would type the command cd C:\Users\Daniel\Documents to change to the directory where you save the .class file. Then just follow the instructions that page gave.

You can check if you have properly installed Java by typing the command java -version - if you get no errors then you should be good.


I've downloaded the most recent Java Version 8 Update 121, however when i run the command "java -version-" it says "unrecognized option: -version-" "Error: Could not create the Java Virtual Machine." "Error: A fatal exception has occurred. Program will exit."
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The command is

java -version

How to check Java is installed ok

You might also want to start learning how to use search engines - it's pretty amazing how many answers those things can find when you type in any kind of question in your browser's address bar.
 
Daniel Harbsmeier
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:The command is

java -version

How to check Java is installed ok

You might also want to start learning how to use search engines - it's pretty amazing how many answers those things can find when you type in any kind of question in your browser's address bar.


Sorry I've just procrastinated a lot on this project and its due at 6 am. When I checked the version my Java version is correct, my Java(TM) SE Runtime environment is good, and Java HotSpot(TM) is good. Still won't open the .class file.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What command did you type? Did you follow the instructions on that page?

When you type the command

dir

Is the .class file that you downloaded listed?
 
Daniel Harbsmeier
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:What command did you type? Did you follow the instructions on that page?

When you type the command

dir

Is the .class file that you downloaded listed?


I've downloaded the .class file from the link. Then I opened my terminal window, and typed "cd\" > "cd users\Daniel\documents" > "CASimulator.class" Then it attempts to run the program and says that "Java Installation Not Completed" "Unable to install Java"

When I type "dir" the .class file is not there to be seen.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Harbsmeier wrote:Sorry I've just procrastinated a lot on this project and its due at 6 am

You do understand that moderators on this site are all volunteers, right? If your questions get answered quickly it's because you're in luck and someone is actually still mucking about. It also helps that we have volunteers from all over the world so there are a lot of time zones covered. The fact remains that you shouldn't rely on quick responses here and if you have something urgent you need to get done, that's not really our problem.
 
Daniel Harbsmeier
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:
Daniel Harbsmeier wrote:Sorry I've just procrastinated a lot on this project and its due at 6 am

You do understand that moderators on this site are all volunteers, right? If your questions get answered quickly it's because you're in luck and someone is actually still mucking about. It also helps that we have volunteers from all over the world so there are a lot of time zones covered. The fact remains that you shouldn't rely on quick responses here and if you have something urgent you need to get done, that's not really our problem.


I never meant to suggest that it was your problem. I was just providing an explanation for why I didn't use the "Search Feature." I assumed you were better equipped to assist me with what I needed directly opposed to combing through the searches. Sorry if I've offended you.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about you just use Windows File Explorer (not the web browser) to look at that directory where you think you saved the .class file? Can you see it that way? If you're sure you saved the file, then you should be able to see it in the directory.

Are you actually reading the instructions on that page? Doesn't seem like it because you've posted twice that you typed a command that is not what was instructed on your homework page. Read and follow the instructions you were given!
 
Daniel Harbsmeier
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:How about you just use Windows File Explorer (not the web browser) to look at that directory where you think you saved the .class file? Can you see it that way? If you're sure you saved the file, then you should be able to see it in the directory.

Are you actually reading the instructions on that page? Doesn't seem like it because you've posted twice that you typed a command that is not what was instructed on your homework page. Read and follow the instructions you were given!


Yes, I can find it in my documents. I click on it to execute, and it will not open. If I do what it says on the page, where i type "java CASimulator 20" it just says "Error: Could not find or load main class CASimulator."
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Harbsmeier wrote:Sorry if I've offended you.

You haven't offended me so no apology necessary. We do expect folks to put in some effort in helping themselves though and a little show of independence goes a long way in building up goodwill and making people actually want to help. It's been a long day so if my responses seem a little curt it's because I'm a little annoyed that my efforts to help haven't been successful yet and I'd really like to go to bed not wondering if you're still stuck. I still have an early appointment with my endocrinologist tomorrow morning, or I guess now I should say this morning.
 
Daniel Harbsmeier
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:
Daniel Harbsmeier wrote:Sorry if I've offended you.

You haven't offended me so no apology necessary. We do expect folks to put in some effort in helping themselves though and a little show of independence goes a long way in building up goodwill and making people actually want to help. It's been a long day so if my responses seem a little curt it's because I'm a little annoyed that my efforts to help haven't been successful yet and I'd really like to go to bed not wondering if you're still stuck. I still have an early appointment with my endocrinologist tomorrow morning, or I guess now I should say this morning.


Then by all means get some sleep man! No need to worry. I'll keep fooling around and searching for some answers. No worries. I appreciate your help thats gotten me this far. Take care!
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One last try and then I really have to hit the sack...

Go to your command prompt

cd to whatever directory that .class file is saved in

Type the command you were instructed to type to run the program.
 
Daniel Harbsmeier
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:One last try and then I really have to hit the sack...

Go to your command prompt

cd to whatever directory that .class file is saved in

Type the command you were instructed to type to run the program.


I LOVE YOU. It worked. Go to bed you beautiful human you.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to run that program on my Mac just now, exactly how I've told you to do it. You won't see anything come up on the display, it'll just sit there looking like it's doing something in the background, then exits and comes back to the command prompt. If you look in the directory again though, you'll see a bunch of Experiment_**.html files will have been created. If you have Windows File Explorer open and navigate to the directory where the .class file is, you might be able to see the Experiment_**.html files appearing as they get created by that program.

Good luck, I'm out for the night.

EDIT: Ok, I see you got it to work, too. Later, dude.
 
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Have you had any success finding that file and running it? You appear to have
java -version
working OK, but what happens when you run a slightly different command?
javac -version
It won't say anything about HotSpot, but it shou‍ld give you a version number. Is that the same version as with the earlier command?
 
Ranch Foreman
Posts: 3072
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think they're trying to compile, just run a class they've been pointed to.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!