Question:

Question about running java programs without the IDE?

by  |  earlier

0 LIKES UnLike

Hi i have a really stupid question about java, but please bear with me lol.

I am learning to program with java (im at the point where i am starting to use OOP). At the moment, all of the programs that i have written are made into '.java' files, and '.class' files.

What i want to know is how are these programs then made into a program that can be run without needing the IDE.

For example when i download a java program off the internet (such as off the sun website), all i have to do is double click on the file and it opens up in a new window?

Cheers for all your help!!!

 Tags:

   Report

2 ANSWERS


  1. One way is to make it an executable jar file.

    Or write a batch script to run it. which would consist of (if your class path is set)

    cd c:\myFolder

    java myPorgram

    or create another program in C or other language that will run your file.  


  2. java programs off of the internet that you can double-click to run are usually in one of two file types: executable files (ending with .exe) or self-extracting jars (ending with .jar). If you are just starting java, you shouldn't worry about trying to make jar or exe files. If you have .class files, that means you have already compiled the program using javac.exe (if you didnt use it, it means you used a IDE). Are you familiar with the command line? I assume so, if you used javac. if not, google it. anyway, open command line and go to the folder where your .java and .class files are, and type "java whatevermyprogramiscalled". this should run that file in command line. Note: do not use the extension! If you get tired of having to use the command line each time, you should get an IDE. I suggest Eclipse.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions