Results 1 to 14 of 14
- 07-03-2012, 06:43 PM #1
Member
- Join Date
- Jun 2012
- Posts
- 7
- Rep Power
- 0
I can compile my progam but I can't run it!
Here is the code:
Java Code:package me.mikaelafiery.TextBasedRPG; import java.util.Scanner; public class FirstGame { public static void main(String[] args){ String Gamemode; String axe; String playername; Scanner gmscanner = new Scanner(System.in); Scanner axescanner = new Scanner(System.in); Scanner namescan = new Scanner(System.in); int notvalidcounter = 5; int itemaxe = 0; int health = 100; System.out.println("Welcome to Mika's first game!"); System.out.println("Which Gamemode would you like to choose?"); System.out.println("Type 'tutorial' to see how to play the game"); System.out.println("Or type 'start' if you already know how to play"); Gamemode = gmscanner.nextLine(); if(Gamemode.equals("tutorial")){ System.out.println("There are various choices in the game"); System.out.println("If there are new choices you will be informed"); System.out.println("The choice 'ignore' is usually unneccesary but it sometimes"); System.out.println("Now to start the game just type 'start'"); Gamemode = gmscanner.nextLine(); } if(Gamemode.equals("start")){ System.out.println("What's your name?"); playername = namescan.nextLine(); System.out.println("Health: " + health); System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println("You see a pile of axes!"); System.out.println("Will you 'grab one' or 'ignore'?"); axe = axescanner.nextLine(); if(axe.equals("grab one")){ itemaxe++; System.out.println(playername + ": I'll probably need this..."); }else if(axe.equals("ignore")){ System.out.println("*You ignore the axes*"); } System.out.println("You see a village in the distance!"); }else{ System.out.println("That option is not valid!"); System.out.println("Goodbye"); }System.exit(0); } }
- 07-03-2012, 06:48 PM #2
Re: I can compile my progam but I can't run it!
What do you mean you can't run it? How are you trying to run it? What happens when you try? Do you see an error message? If so, what?
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 07-03-2012, 06:53 PM #3
Member
- Join Date
- Jun 2012
- Posts
- 7
- Rep Power
- 0
Re: I can compile my progam but I can't run it!
I used the Command Prompt!
I did
javac FirstGame.java
then I did
java FirstGame
But it came up with this error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: FirstGame : U
nsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: FirstGame. Program will exit.Last edited by mikaelafiery; 07-03-2012 at 06:57 PM.
- 07-03-2012, 06:59 PM #4
Re: I can compile my progam but I can't run it!
Did you google that error message?
That's a result of compiling with a newer version of Java, like Java 7, but trying to run your code with an older version of Java, like Java 6.
Check which version of javac (probably 7) and java (probably 6) you're using. You might have to look at your path specification.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 07-03-2012, 07:03 PM #5
Member
- Join Date
- Jun 2012
- Posts
- 7
- Rep Power
- 0
Re: I can compile my progam but I can't run it!
Last edited by mikaelafiery; 07-03-2012 at 07:25 PM.
- 07-03-2012, 07:26 PM #6
Member
- Join Date
- Jun 2012
- Posts
- 7
- Rep Power
- 0
Re: I can compile my progam but I can't run it!
This is really complicated stuff :'(
- 07-03-2012, 07:33 PM #7
Member
- Join Date
- Jul 2012
- Posts
- 17
- Rep Power
- 0
- 07-03-2012, 07:42 PM #8
Member
- Join Date
- Jun 2012
- Posts
- 7
- Rep Power
- 0
- 07-03-2012, 07:54 PM #9
Member
- Join Date
- Jun 2012
- Posts
- 7
- Rep Power
- 0
Re: I can compile my progam but I can't run it!
The classpath seems correct:
.;C:\Program Files (x86)\Java\jre7\lib\ext\QTJava.zip
but it still is running it on jre6 :/
- 07-03-2012, 08:00 PM #10
Member
- Join Date
- Jul 2012
- Posts
- 17
- Rep Power
- 0
Re: I can compile my progam but I can't run it!
it should be C:\Program Files (x86)\Java\jre7\bin as i said.
FYI
Classpath is path to executable files of your system, you can find java.exe in the above path.
referring that your program will be executed.
also please check if the referance to your old runtime environment is not there in classpath.
- 07-03-2012, 08:09 PM #11
Re: I can compile my progam but I can't run it!
Classpath != path.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 07-03-2012, 08:15 PM #12
Member
- Join Date
- Jul 2012
- Posts
- 17
- Rep Power
- 0
Re: I can compile my progam but I can't run it!
- 07-03-2012, 09:34 PM #13
Member
- Join Date
- Jun 2012
- Posts
- 7
- Rep Power
- 0
- 07-04-2012, 09:45 AM #14
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
why won't this compile
By joet1984 in forum Advanced JavaReplies: 4Last Post: 08-31-2011, 09:50 AM -
What to do here(cant compile)?
By Pojahn_M in forum New To JavaReplies: 8Last Post: 08-06-2011, 01:55 AM -
would this compile?
By stringkilla in forum New To JavaReplies: 10Last Post: 10-24-2010, 03:27 PM -
Can't Compile
By sidk47 in forum JavaServer Pages (JSP) and JSTLReplies: 7Last Post: 06-15-2010, 04:43 PM -
Not able to compile
By bugger in forum New To JavaReplies: 2Last Post: 01-09-2008, 10:13 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks