Click to See Complete Forum and Search --> : How to use .java file to run without java and eclipse enviroment
Hello everyone :) Tnx 4 payin attention :)
i wrote a program in java (eclipse), and i want to run it without using eclipse
Does anyone knows easy way for doing this?
Anyways, thanx a lot:)
Khalid Ali
08-15-2009, 09:49 AM
well I am guessing you have
1.installed jdk
2.Set the system paths to jdk/lib and jdk/bin directories
if you have done the above then your program will work, otherwise no. And if you have then you need to do the following
java myprogramclassname.class
thats it.
If you have issues or need more detail on how to setup paths and such, read the sticky at the top of the forum for troubleshooting
i followed ur suggestions, i have set the path and everything and thanx alot for helping
just i have another question when i type command in prompt where i have to compile and run my program, exactly where i have to put my HelloWorld.java file? and is there another requirment to put with .java file?
i tried just to run any program, but it didnt work
thanx anyways:)
Khalid Ali
08-16-2009, 12:17 PM
*.java files are java source code files, you need to convert this file to java compiled (byte code) file. You can do this by using
javac yourclassname.java
This will produce the class file, then and only then yo will use
java yourclassname.class
to run it.
To see if paths are set correctly, on command prompt type this and hit enter
javac
if you get an error like javac is not a known command that means path is not set. and use the same for
java
if no errors then compile the *.java and then run the *.class file.
Post your errors here if still no success
thanx a lot again :) i have set path and there is no errors with it, just when i create .java files is there any restriction for the location where i have to put them? because when i created any simple code and kept it as java file it gave me the following error:
C:\Documents and Settings\Administrator>java HelloWorld.java
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/java
tnx :)
Khalid Ali
08-17-2009, 09:50 PM
There could be 2 issues here, as I said earlier you CAN NOT run *.java files using java classname.java, YOU MUST compile it to *.class file. You can do this by doing the following, cd the folder where HelloWorld.java file is located.
Second issue may be because of the spaces in the name of the folder.
create a folder named development
then put your files there
C:/development
HelloWorld.java
now once in the development folder write this at command prompt
javac HelloWorld.java
the above will produce the class file in the same directory
NOW and ONLY now you can use
java HelloWorld.class
Hello again and tnx a lot for ur help :) i could easily compile and run my programs, but when i tried to compile programs containing JFrame, JDialog, then it gave me the following notifications:
C:\Documents and Settings\katamadze_s\development>javac main.java
Note: main.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
tnx :)
criterion9
08-19-2009, 08:55 AM
That is just a notice telling you that some of the code you are using is depreciated and you should probably try learning the newer method. Your code will still run just fine.
yeah, but problem is that program must show JFrame, but nothing is being displayed. Usually, when i compile such program in eclipse JFrame or any other GFI tools are displayed (which i include in it). Notification tells me to recompiler it i guess with another command...
criterion9
08-19-2009, 10:21 AM
That message has nothing to do with things being displayed or not. You are probably missing some code that the IDEs provide for you.
tnx a lot :) u helped me a lot
it works now, just i had used older version of one function