Results 1 to 4 of 4
- 05-02-2011, 02:19 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 11
- Rep Power
- 0
cant use Command Prompt to run Java App (with screenshot)
Just HelloWorld "application" like this
the .java file is in C:\Examples\je3\basics
PHP Code:package je3.basics; public class Hello { public static void main(String[ ] args) { System.out.println("Hello World!"); } }
but when I use java to run it:
even I've try changing the path to the .class file. It's still not OK
this is my java version and javac version:
My Environment Variables:
CLASSPATH and JAVA_HOME:
Java Code:.;%JAVA_HOME%;
Java Code:C:\Program Files\Java\jdk1.6.0_25
-
event I can use Eclipse or other IDE to run it. I really do want to know how to do it (run my little HelloWorld app just with JDK and Command Prompt).
- 05-02-2011, 03:51 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,638
- Rep Power
- 12
You've defined your class to be within a package, so compile and run the class(es) from the root of the package (eg cd up to the Examples directory, then javac (or java) the class from there je3/basics/Hello
See Creating and Using Packages (The Java™ Tutorials > Learning the Java Language > Packages)
- 05-02-2011, 04:25 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 28
... or alternatively, don't specify a package for the class; I don't recommend this option because you are going to meet the troubles of packages later again, but it is a quick fix/hack for now.
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
- 05-03-2011, 04:24 AM #4
Member
- Join Date
- Mar 2011
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
how to make command prompt in java
By udinulis in forum Java 2DReplies: 4Last Post: 07-14-2010, 07:52 AM -
running command prompt using java
By xclaim in forum New To JavaReplies: 1Last Post: 01-14-2010, 04:46 AM -
Command Prompt Java
By kelvinsmj in forum New To JavaReplies: 8Last Post: 11-27-2009, 11:30 AM -
Is there any way to run java file through command prompt of .jar
By sachin.parnami in forum New To JavaReplies: 2Last Post: 12-03-2008, 02:24 PM -
accessing command prompt using java (netbeans)...
By kureikougaiji in forum New To JavaReplies: 6Last Post: 06-27-2008, 04:01 PM
Bookmarks