java virtual machine launcher error: unable to access jarfile - java

I have downloaded a program to run on windows XP.
According to the instructions, opening the .bat file that includes the command that calls the .jar file would be enough.
Yet the program does not open.
In a friend's computer the program does open.
I have set correctly the java-related environment variables. Java works fine. I have associated .jar files with java sdk.
When calling the command
javaw -Xms128M -Xmx512M -jar filename.jar from cmd
I get a java virtual machine launcher
error: unable to access jarfile
Then I called the same command while being on the folder where the jar is, I have no error, but still the gui of the program does not open.
Any ideas?
On windows support the suggest unistalling and manually re-installing java, but java works fine in any other app.

Try some of the following:
Run directly from the .exe, so "C:...\jre\javaw.exe" -jar
Try java -jar instead of javaw -jar.
Try moving the file. It could be in a permissions sensitive directory.
Also, if the program was compiled using a 64-bit JDK, it might require a 64-bit JRE to run. In that case, you'd need to have a 64-bit OS/JRE to run it.

Related

Cannot open .jar files with java installed (windows 11)

Environment: Windows 11
Problem: cannot open .jar file(the MARS assembly language simulator)
Hello, I am currently trying to install the MARS assembly language simulator. It is a .jar file so I downloaded java to open it. However, I still can't open the file even with java downloaded.
I checked if java was installed using my cmd:
Command prompt showing java successfully installed
I tried double-clicking it did not work. So I right-clicked it to open with other apps. But I did not see java in the given options.
Cannot find the java option to open the file
Thank you so much for helping!
Use your prompt
CD into the directory with the jar
then execute
java -jar Mars.jar
...any more troubles , open file properties tab with right click on the jar and check permissions to execute the file.
Installing Java usually means installing a JVM, which is a Java Virtual Machine. You won't be able to launch files from a Windows context menu like this, because "Java" is not a program that opens files.
Instead you need to:
Either a terminal and call javaw.exe with the parameters -jar and your .jar-file. E.g.:
C:\your\java\binaries\javaw.exe -jar -SomeJarFile.jar
Or add the Java installation to your environment variables, then you can call javaw.exe without providing some specific path

My simple Java program runs with no problem on Eclipse, however can't find Java in my pc

I have a Windows laptop provided by my employer. I don't have admin rights. I was able to download Eclipse for Java and run a very simple program that printed to the console "hello world". However, I'm not able to find the Java files. I used the cmd command java -version and it does not recognize it. I looked in the Local disk > program files, and didn't find Java there either. Can someone explain what is going on?
Long story short:
Eclipse has it's own compiler, it does not use the JDK compiler.
So it makes perfect sense that Java is not installed but yet you are able to run the code from Eclipse.
You can only use command "java -version" in console if the windows system variable Path contains the "path" to the folder where java is located.
ie:
variable: Path
value: C:\Program Files\Common Files\Oracle\Java\javapath
Go to system properties and look for environment variables.
Try to go to eclipse folder and you will see jdk ,java and other files. Copy that java folder path and run command java -version in a Terminal

JAR is executed with terminal but not with direct clicking

I have tried the following:
in terminal it works
In Intellij it works
I have tried to launch it with javaw.exe but nothing changes
Are there any other options?
This looks like an OS problem that an application building one -- because you said that it works in your IDE and terminal.
Make sure that you installed Java properly in your machine.
In Windows/MacOs, after installing Java, the *.jar files are automatically associated with the java -jar command and makes it runnable via double-click.
In linux, this varies on the flavour or DE you are using. But there's probably a utility in your OS to open *.jar files using java -jar command.

how to run executable jar file on one machine from other machine

I have a executable .jar file in a remote machine in windows environment. Now I want to execute this .jar file from other machine (windows environment) and need to open the console.
So far, I have shared the specific .jar file to everyone and created a .bat file in local machine with the below content.
#ECHO OFF
java -Xms512m -Xmx768m -XX:CompileThreshold=8000 -XX:PermSize=256m -XX:MaxPermSize=512m -Dvendor=shell -DvendorFile="\\<REMOTE MACHINE'S IP>\WorkJars\servers_prod_remote.properties" -Dfile.encoding=UTF-8 -Dyfs.logall=N -jar "\\<REMOTE MACHINE'S IP>\Users\tcs\Desktop\Status Compare\statuscompare4.jar"
It works fine for some machine, but for other machine, it fails and it prompts for the username and password of the remote machine.
Even if I try accessing the remote path from local using run command \\<REMOTE MACHINE'S IP>\, for some machine, it prompts for the username and passoword for security.
Security Prompts
So whenever, I use .bat file from those local machine, it says "Access Denied".
Could anyone help me with this issue, as I don't want the username and password to be prompted and I just want to execute the .jar file without any issues.
If the jar file is excute on your machine, then the file is ok no issue with file.
Now your problem is it is not executing on some of the other machine not all. Its simple java need JRE to run or JDK for development.
Downlaod JRE java runtime enviroment from Oracle on the machine on which the file is not running and test it.
hope your problem is solve.
Another way is to quicky test if JRE is installed on the machine.
Open comand promte by clicking on start and type cmd. then type java - version
if it display some verison of java or something that means JRE is installed otherwise some other issue.

Can't run .jar classes from .sh on Linux that work on Windows via .bat

I'm having a strange issue trying to run classes from an executable .jar file on Linux that none of the existing question threads I've sorted through seem to be able to resolve. I'll preface this in that I've never had to use Linux before and am only using it in this situation out of necessity, so it's possible I have overlooked something simple that I just didn't know could be causing the problem.
I can launch the classes from my .jar file without any issues on Windows via a .bat file with the following settings:
start "MyServer1" java -classpath ./*;Server.jar infoServer/StartInfoServer
start "MyServer2" java -classpath ./*;Server.jar loginServer/StartLoginServer
start "MyServer3" java -classpath ./*;Server.jar chatServer/start
start "MyServer4" java -classpath ./*;Server.jar gameServer/start
However, when I move to trying to launch these classes from the .jar on Linux, I get a "could not find or load main class" error. My .sh file is set up like this, and is placed in the same directory as my .jar file:
echo Starting Servers
java -cp Server.jar infoServer.StartInfoServer
java -cp Server.jar loginServer.StartLoginServer
java -cp Server.jar chatServer.start
java -cp Server.jar gameServer.start
echo All Done Starting Server
I've used ls from the Terminal to verify the .jar and .sh were being recognized as existing where they should be. (For future note, I'm using the Terminal from inside the directory containing my files.) I've made sure to make use of chmod to be sure both the .jar and the .sh have read/write/execute permissions and used ls -l to verify those permissions were indeed present. I've tried various forms of explicitly defining the classpath, such as using "/home/machine/Desktop/Folder/MyJar.jar", using pwd from the Terminal to ensure I'm getting the filepath correct. I've checked over my Java compatibility. (1.7.0_65 on Linux, 1.8.0_45 on Windows, with the .jar being created in Eclipse using 1.7 Compliance settings.) I can use unzip MyJar.jar from the Terminal and it will properly extract all my class files, allowing me to verify that my .jar isn't corrupted on my Linux machine and that the paths to the classes I'm trying to run are still the same on Linux as they are on Windows.
I do apologize if this is just a problem of inexperience overlooking something, but I can't think of or find any indication of what the problem could possibly be.
EDIT:
I've updated the question with some screenshots related to the problem:
https://gyazo.com/0ae2a2701aae734db21ef7c29200283b - General File Setup.
https://gyazo.com/d735d9cee57b4a92078c4b624d012b8c - Running the Shell via Terminal.
Other notes: jar -tf Server.jar works from the Terminal but not from inside the Shell script, which leads me to believe this may be some kind of visibility or pathing error, but I can't find any reason why that would be the case.

Categories

Resources