• Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting Java to Exe error  RSS feed

 
Hank Harrison
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I compiled a java program and converted it to an exe file and it works fine on the computer I created the java file in but when i try it on another computer it gives me a "Java Virtual Machine Launcher - A Java Exception has occured" error message. Any ideas what could be causing this and how i could fix it? Thanks in advance.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hank Harrison wrote:Ok so I compiled a java program and converted it to an exe file and it works fine on the computer I created the java file in but when i try it on another computer it gives me a "Java Virtual Machine Launcher - A Java Exception has occured" error message.

Is that ALL it says; or is there more detail?

Any ideas what could be causing this and how i could fix it?

All sorts of things, but it sounds to me like something essential wasn't "packaged" with your exe.

Winston
 
Hank Harrison
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so when I upgraded the other computer to Java 8 that seemed to fix the problem. My next question is, is there a way to save the java file to make it compatible with previous versions of Java? or does the other user have to always upgrade to java 8 in order to use the program? Thanks.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally, when you compile your code with JDK 8, then the user will need Java 8 or newer to run it.

There is a way to compile code with JDK 8 and make it run on older versions of Java: use the -source and -target command line options of the Java compiler. When you do that, however, you cannot use new language features that were added in Java 8. Also, you should not call methods or use classes or interfaces from the standard library that were new in Java 8. Note that the Java compiler will not protect you if you do: it will just compile the code, and when you then later try to run it on Java 7 or older, you might get an error because some method, interface or class does not exist. Therefore, if you want to be sure your code is runnable on an older version of Java, it is better to download and use the JDK for that version, and compile your code with that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!