Running .jar file through c# on windows?
I wrote a program that downloads a jar file, then runs it. It works perfectly on linux but not on windows, does anyone know what the issue could be? (posting code in a sec)
48 Replies
here's the code for hte main thingy
here's the code for the shell helper thing
GitHub
GitHub - ikvmnet/ikvm: A Java Virtual Machine and Bytecode-to-IL Co...
A Java Virtual Machine and Bytecode-to-IL Converter for .NET - ikvmnet/ikvm
Try running the jar via IKVM, it probably does exactly what you're trying to do here.
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
Oh lol
I might as well just use IKVM and hope it doesn't break anything :3
Can you explain in a couple of sentences the thing you're trying to do? Is all you want to do invoke the jar from a dotnet exe?
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
basically yeah, tho idk what you mean by invoke in this context
run is what I meant
like execute
So you don't need any sort of interop between the jar and your c# code.
Then
Process.Start
might be the simpler option for you (in comparison to IKVM)that's bascially all I wanna do yeah
I'm not sure if process has a run function
made a typo, sorry
doesn't show up in autocomplete
I'm already using process.start
Exactly. I'm suggesting you to keep doing that :)
oke
anyways, since java_home isn't the actual jar, how would I find the jar from there (or if there even is a jar on the computer in the first place)
weh
first off, java itself does not run from a jar. the
java_home
variable should point to the root folder of the primary jdk/jre installation, actual exe is bin/java.exe
ah so Environment.GetEnvironmentVariable("%JAVA_HOME%") + "/bin/java.exe" would work?
don't think you'll need the
%
s in your variable nameok fair
would only need that in something like a batch script
I added that cuz I was desperate
I'll tell u if it works My friend has to run it
do you not have java installed on your machine?
no I'm using linux
is your project not using .net core? modern c# is xplat
although on linux you likely wouldn't need to specify any path for java, i would expect it to be on the system path after installation
but i haven't installed java on linux outside of vms / docker containers in a long time
ok he was thrown this error on windows
on linux it's way more straightforward than on windows
current code
it's not much more difficult on windows, just seems like you don't really know your way around the OS
I have not used windows in like 6 months and it's only on my school computer
lol
¯\_(ツ)_/¯
can always spin up a windows VM for your own testing
would make this process much easier than bouncing back and forth through an intermediarity with no ability to debug
and by reading that error message the issue should be easy to spot
wait
is java home null in this case
An error occurred trying to start process '/bin/java.exe'
yes, there is no environment variable named java_home on their PC
JAVA_HOME isn't part of the java installation nowadays iircis there an easier way to do this?
sure, open up a file picker dialog and make them locate the java folder and save that in some kind of config
¯\_(ツ)_/¯
or assume java will be on the system path and make users configure that
I'm trying to avoid the user having to pick files and stuff
windows why can't you be like linux and put stuff in consistent spots
? the java install should put it on the system path afaik
otherwise include a readme that tells people how to set up the JAVA_HOME variable or how to update the system path to include it
wouldn't be hard to include fallback logic, attempt to read and validate JAVA_HOME and, if that fails, attempt to start
java.exe
which should work if it is on the system path
and again, developing this would be much, much easier if you set up a windows VMhttps://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html would this be a good thing to link them to for setting up java home if the fallback doesn't work?
seems fine
IT WORKS
YIPPEE
anyways rq
I forgot what the command to publish the app without the person using it having to download .net sdk
https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli
should have the info you need
Create a single file for application deployment - .NET
Learn what single file application is and why you should consider using this application deployment model.
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
If you have no further questions, please use /close to mark the forum thread as answered
the lino that you sent me in private were of hacking or trolling? Anyway, that was very rude and disrespectful.
.
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
Unfortunaly no, i spoke to him in private, invinting him to a project, then he said he had to make sure i was not a bot and that i should click a link. I clicked in it and it got to a site saying something like ´´they stole my computer, were going to share it``
really negative expirience
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
Weird is too much of a subjective trait
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
I think i may get into the form of an art director who got a bit off thanks to studying philosophy and so on
dude? hahahaha, were are you guys taking that from?