So I have the latest version of JRE 7 on my computer, and everything is working fine. Lately, I've downloaded a program that requires JRE 6. I know where all of the files are located on my computer, all I'm asking is the .bat file code to run a specific version of Java with only that program. I am somewhat of a newbie when it comes to Windows and Java PATH structure, so
Stanford's computer science course has you use a modified version of Eclipse to code in Java, and it was created when Java was still in version 6. If you are familiar with this, then you may know of karel the robot, a Java application that opens in Eclipse. When I tried to run this, the Karel program did not appear; only a blank screen. I found a youtube video about using Karel and many of the people in the comments had been having this problem, and some said that using JRE 6 fixed it. Also on the installation instructions, it said to use JRE 1.6, but I thought it would work with JRE 7
you can call each java.exe directly.
You can create 2 batch file named java6.bat and java7.bat :
java6.bat
#echo off
"C:\Program Files\Java\jre6\bin\java.exe" %*
java7.bat
#echo off
"C:\Program Files\Java\jre7\bin\java.exe" %*
to call a program with jre6
java6 -jar helloworld.jar
and to call a program with jre7
java7 -jar helloworld.jar
If you mean this program then I had no problem launching it with java 7
However if you really need java 6 for operating it then you could write some .bat file like this:
#echo off
set JAVA_HOME=C:\oracle\jdk1.6
set MY_CLASSPATH=lib\karelj.jar;lib\silk.jar
%JAVA_HOME%\bin\javaw.exe -cp %MY_CLASSPATH% karel.swingui.Main
Related
It's definitely installed, I can run Minecraft. But I'm trying to run a .jar file and Windows 11 is asking "How do you want to open the file?" And java compiler doesn't show up. btw I've treid where java, it said java didn't exist on the computer
UPDATE: I solved the problem but not the issue, there were some mods that were incompatible with eachother
You could try to find it out via printing your PATH.
On Windows: Open the command line via
Start -> CMD
Paste in
echo %PATH%
There you should be able to find the java path. Otherwise try to search for JRE.
By the way it is not always 100% sure that you have the java runtime and java compiler installed.
JRE = Java Runtime Environment for executing .jar
JDK = Java Development Kit for compiling java files and creating .jar files
I have an old program that runs on JRE 1.6, when you upgrade beyond that the program will not log in.
I've looked into upgrading it but cant seem to make it compatible with later JRE versions.
Problem is customers keep upgrading the JRE on the machine it runs on, even when told not to.
Is it possible to install 2 JRE on a machine and specify which one to use when running my program?
I was thinking if the class path points to JRE 1.8 but i didn't use the classpath but the full address of the JRE 1.6, would that work ?
Edit:
java -Djava.library.path=lib/ -classpath .;lib/Serialio.jar;lib/log4j.jar;lib/client.jar -Djava.security.policy=java.policy 192.168.0.10 1098
this is my bat file, i've tried replacing -classpath with C:\jre1.5/bin/java.exe -jar but it thinks thats the name of my main class not the new class path, what am i doing wrong
Is it possible to install 2 JRE on a machine and specify which one to use when running my program?
YES, if you execute the jar, you can run it from an specific JRE
path_to_jre/bin/java.exe -jar YourApp.jar
Simply put the above line in a .bat file for your customers and double click will execute the program with defined java version, allowing your customers to upgrade java for other apps without problem.
java -Djava.library.path=lib/ -classpath .;lib/Serialio.jar;lib/log4j.jar;lib/client.jar -Djava.security.policy=java.policy 192.168.0.10 1098 is my bat file, i've tried replacing -classpath with path_to_jre/bin/java.exe -jar it thinks thats the name of my main class not the new class path, what am i doing wrong
your bat file must be something similar to this (path to java is my own one):
C:\Program Files\Java\jre6\bin\java
-Djava.library.path=lib/
-classpath .;lib/Serialio.jar;lib/log4j.jar;lib/client.jar
-Djava.security.policy=java.policy 192.168.0.10 1098
I tried GCJ and it compiled fine. I tried both for Ubuntu and windows. The compiled file is running on my Ubuntu machine as well the .exe with wine. But if I tried to run in on my Ubuntu server I got this error:
error while loading shared libraries: libgcj.so.14: cannot open shared object file: No such file or directory
But I thought I would not need to install anything to run "native" code. I also could not run the .exe on a windows machine.
Could you please tell me why this is happening? Maybe I'm compiling wrong. I use this: gcj --main=Hello -o hello.exe Hello.jar for windows.
When you run an executable it is very common to need a shared library, whether you use Visual Studio .NET or Java or C++.
When you compile a program for a specific platform, it usually only works on that platform or similar. If you want to run this program on Windows, you need to compile it for windows.
BTW GCJ is pretty old and out of date. I suggest you use Java 7 or 8. This will avoid the need to install additional libraries and will run on Windows or Linux without re-compiling.
I'm in a Java I class and I have a new-ish laptop with Windows 8 on it. I've installed Java and changed the environment variables, created a Path, etc. When I enter java or javac in the cmd, it comes back with information. But when I enter "java-version" (as I'm instructed to do in the class to test if Java is working) it says, "'java-version' is not recognized as an internal or external command, operable program or batch file".
I've even attempted a HelloWorld program in spite of this, and as you can imagine, I got the same message. I'm not even able to change the directory.
Is there some special way to install this on Windows 8 or what?
You need to type java -version instead of java-version
First of all ensure you have typed Java -version space between Java and -version
No there's not special way to install Java on windows 8 machine, Just ensure that you have added ..\Java\jdk_(version)\bin and ..\Java\jre\bin in environmental variables.
Steps to be followed :
Right click on my computer go to properties
Then go to Advanced
system properties then click on environment variables
and add both path in Path variable under System Variables add semicolon between two paths
after all process don't forget to restart your PC
There is no special way to install java on windows 8. You can install java in normal way what you did in windows 7 or vista or windows xp and configure. Then run java -version, It will give your java version.
I've written a relatively simple java application. I have JDK on my PC, but I need it to run on a mac for school. The .jar runs perfectly on my PC, but I tested it on my Macintosh (which, BTW, does not have JDK installed).
Why isn't it running on mac? How can I fix this? Is fixing it even possible?
You don't need JDK to run Java based programs. JDK is for development which stands for Java Development Kit.
You need JRE which should be there in Mac.
Try: java -jar Myjar_file.jar
EDIT: According to this article, for Mac OS 10
The Java runtime is no longer installed automatically as part of the
OS installation.
Then, you need to install JRE to your machine.
Make Executable your jar and after that double click on it on Mac OS then it works successfully.
sudo chmod +x filename.jar
Try this, I hope this works.
I made the jar file executable as indicated by #Java D: sudo chmod +x filename.jar, and then I ran from the terminal Java -jar filename.jar as indicated in another answer by #Hardik Mishra. The installation process will start right after it.