| | |
Running Java Program outside an IDE
![]() |
javaw is designed for that (launches the JVM but without a command window) again needs to be in your path. Then create a windows shortcut with the necessary command. See here for more info:
http://java.sun.com/j2se/1.4.2/docs/...dows/java.html
http://java.sun.com/j2se/1.4.2/docs/...dows/java.html
•
•
Join Date: Apr 2006
Posts: 164
Reputation:
Solved Threads: 10
To compile the code you have to type:
javac myapp.java
it will create a myapp.class file in the same or diff location... then just follow it and type java myapp it will run the code... you have to compile before running... you may have to setup the classpath to include your JRE in your environment... you can follow this:
go to Start menu-> My Computer (right button click) select Properties -> Advanced ->Environment Variables-> CLASSPATH click on Edit, and set the path location of your jre... typically it is under Program Files/Java/jre1.x.0_xx here x is some number.
javac myapp.java
it will create a myapp.class file in the same or diff location... then just follow it and type java myapp it will run the code... you have to compile before running... you may have to setup the classpath to include your JRE in your environment... you can follow this:
go to Start menu-> My Computer (right button click) select Properties -> Advanced ->Environment Variables-> CLASSPATH click on Edit, and set the path location of your jre... typically it is under Program Files/Java/jre1.x.0_xx here x is some number.
A Perfect World
Once you install Java, you should be able to "double-click" on a .class file and execute it in that way, if you don't have a class file (but just a .java file), then you have to compile it/them first. Better would be, to create a jarfile containing the relevant classpath info and such in the Manifest file so that every thing is handled correctly, and then "double-click" that jarfile.
Obviously.
Obviously.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Sep 2007
Posts: 27
Reputation:
Solved Threads: 3
Best is to use ANT to build your projects to jar files. (or maven if you want to take it a step further).
Download java source code examples from http://java-assignment.com/
N Puzzle game, Magic squares, Huffman compression techniques, ...
N Puzzle game, Magic squares, Huffman compression techniques, ...
•
•
•
•
Best is to use ANT to build your projects to jar files. (or maven if you want to take it a step further).
That said, what real difference does it make what tool he uses to build the jarfiles (once he understands what is happening, anyway)?
Making a jarfile was not suggested only for convenience (which the ANT suggestion was). It could be, and probably is, a very real necessity, if any third party libraries are involved.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
•
•
Once you install Java, you should be able to "double-click" on a .class file and execute it in that way, if you don't have a class file (but just a .java file), then you have to compile it/them first.
What I'm actually looking for is a normal windows EXE file, which when executed launches the Java application. Maybe I can use something like
Java Syntax (Toggle Plain Text)
system("java app.class");
Well a .jar file open with WinRAR on my system! It seems that jarfiles are like a collection of zipped .class files.
You have done something that has changed the file associations on your machine. (For the jarfile one it was the installation of WinRAR.)
Change them back.
.class should be opened with "java" or "javaw" and .jar should be opened with "java -jar" or "javaw -jar". Alternatively, you could de and re install java and let it reset the file associations itself.
Edit: And java.exe (or javaw.exe) should already be in your path if java is properly installed. If not, add the directory containg them to your path, obviously.
All of these things, BTW, are System Maintenance questions, and not Java questions, per se.
Edit Again: All of these, BTW again, would also be non-issues, if you had learned Java the right way, rather than learning it using an IDE (which is really only learning to use the IDE and not learning Java, as illustrated by these questions).
Change them back.
.class should be opened with "java" or "javaw" and .jar should be opened with "java -jar" or "javaw -jar". Alternatively, you could de and re install java and let it reset the file associations itself.
Edit: And java.exe (or javaw.exe) should already be in your path if java is properly installed. If not, add the directory containg them to your path, obviously.
All of these things, BTW, are System Maintenance questions, and not Java questions, per se.
Edit Again: All of these, BTW again, would also be non-issues, if you had learned Java the right way, rather than learning it using an IDE (which is really only learning to use the IDE and not learning Java, as illustrated by these questions).
Last edited by masijade; Oct 4th, 2007 at 10:22 am.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- put the Dos 's command into java program? (Java)
- Running java command thru java program (Java)
- JAVA program help (Student/Grades) (Java)
- Help with a java program home work assignment (Java)
- Wierd Numbers appear when trying to run a running product in a C++ program (C++)
- error on running the parallel program (Java)
Other Threads in the Java Forum
- Previous Thread: Need Help.. please? :D
- Next Thread: Paint Application In Java
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application array arrays automation banking bidirectional binary binarytree birt bluetooth chatprogramusingobjects class classes client code columns component database derby design eclipse encryption error errors expand fractal game givemetehcodez graphics gui guidancer homework html ide if_statement image inetaddress inheritance integer intellij j2me java javadesktopapplications javaprojects jlabel jme jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source print problem program project property recursion reference ria scanner server set sms sort sourcelabs splash sql sqlite static stop string support swing testautomation threads tree ui unicode validation windows






