Text garbling in compiling Java at Cygwin - java

I'm a university student in Japan, and I can't speak English well, but let me ask one question.
I attempted to start Java and installed Java jdk1.8.0_171 including javac and java.
Then, I set PATH at Windows10, and succeeded in compiling one java file.
However, when I attempted another file, Cygwin showed me an error message and it was broken, so called text garbling.
I don't mind that language in Cygwin will be English, so please teach me how to solve this problem.
よろしくお願いいたします。

Related

Can anyone interpret what these instructions mean? Trying to install a JVM to a mac

Please bear with me. I'm a biology student trying to perform Species Distribution Modeling of certain plant species in Australia using R Studio (specifically using a Maximum Entropy model) and I have a limited understanding of the command line.
In order to do this, I need to use the rJava package in R Studio. While the installation seems to work, when I run the command:
library(rJava)
I get this warning message:
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
So I found this tutorial online:
https://github.com/s-u/rJava/issues/86#issuecomment-261039681.
Towards the bottom of the page, the user gwarnes-mdsol gives a step-by-step guide to fixing this problem using my mac's command-line. I am supposed to install Java, uninstall any existing rJava packages, and then run a few lines of code that he wrote out. However, I can't seem to get past this step. What does he mean when he says to add the export command to the the filepath he supplied? Am I supposed to fill in portions of this code with filepaths that are specific to my computer?
# Add the following lines to /Users/<userid>/.bashrc:
# Set JAVA_HOME so rJava package can find it
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)/jre
I'm not sure where to begin with this. I've tried downloading a JDK (jdk-11.0.6_osx-x64_bin.tar.gz) and renaming it JAVA_HOME but then I don't know where to put it in my computer. I don't know where to find a .bashrc file. How can I run this code properly?
Any help is greatly appreciated!

Serial link error and bad path jre 1.7.0_15 32-bi

Trying to make an old java game run on the original PC both ca 2012. JRE 1.7.0_15 (32bit) runs on linux (Puppy 6.3, 32 bit). I can configure the game with java but the next console command to start the game fails with
Exception in thread "AWT-EventQueue-O" java.lang.Unsatisfied LinkError: no serial in java.library.path
...and then more errors.
I don't know java or java syntax. Can you tell from this info what I can type in urxvt console so it finds the serial link? Java was installed clean with the Puppy Package Manager, although a few shared libraries report missing. I found those files in other parts of code and online, but have no clue what to do with them so they're found properly or if that's even the problem.
Mine seems to be a common noob issue, but because I don't know what mounts and where, even the right command will fail without typing the true folder names and addresses which I don't have. Can you tell from the error image? Thank you.

Error: Could not find or load main class - Command line

I read a hundred posts related to this but nothing seems to help my case.
A strange thing is happening with my commands. To start off, for the current task I need to be using textbook libraries from an algorithms book and the installer from that book also sets up Java SE 7. I have Java 8 JDK installed on my pc from before (if that is info worth knowing). So, for example, when I am running programs which involve methods from that textbook library I write java-algs4.
Last night there was something wrong with the Path variables and I wasn't able to compile anything so I was setting some of those and then things started working. However, today, when I tried running java helloworld (after doing javac helloworld.java) I got the error mentioned in the title. Moreover, I could successfully run another class file in the same directory but after I ran it once, I couldn't anymore and got the error again. This seems like black magic to me!
When I echo %CLASSPATH% I get the current directory.
Here are my current java-related PATHs set in my environment variables if this is of any help. The algs4 is the one from the textbook.
In User variables - PATH
C:\Users\Denitsa\algs4\bin;C:\Users\Denitsa\algs4\java\bin;c:\Program Files\Java\jdk1.8.0\bin;C:\ProgramData\Oracle\Java\javapath;
In System variables - PATH
_C:\ProgramData\Oracle\Java\javapath;C:\Users\Denitsa\algs4\java\bin; C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.8.0_31\bin;_
I would really appreciate your help with this, been trying to solve this for a while now!
Thanks.
I was trying to run it without the capital letters in the name. Now it is working.

Java JAR-file could not be launched, Mac

I'm simply trying to open a JAR file on my Mac running 10.9.5.
But can't seem to get it open. I have tried litteraly everything, but I have this error code from console:
Class JavaLaunchHelper is implemented in both /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java and /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/./libjli.dylib. One of the two will be used. Which one is undefined.
One guy said that there are conflict between two files. I just want to open it, have not made anything. Developer wont get back to me.
Can some on you guys check out the jar file?
Thanks in advance! Need help :(
OK i had the same problem weeks ago.
Open terminale and check your default java version.
java -version
after this check your java path
which java
if you want to run your program with your java installation edit your PATHvariable.
PATH=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java:$PATH
export $PATH
then you can run your program for terminal
java -jar ....

Trying to rename a computer OR execute a .bat file in Java

I'm trying to write a script to rename a computer (among other things) but just can't seem to figure it out. I don't really care what method I use to change the computer as long as i can change it. I found out how to read the computer name by doing
String computername = InetAddress.getLocalHost().getHostName();
However, that doesn't seem to offer any help in setting the computer name. Is there a way to set the Computer Name directly in the java console?
If not, or if anyone has better experience in this area, I also wrote a script using powershell 2.0 that renames the computer. I'm trying to figure out how to run that using
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("file location");
I followed the guide here but when trying to run a test .bat file that should just open the command line I just get this output in the java console:
C:\Users\Stephen\Desktop\opencmd.bat is found
OUTPUT>
OUTPUT>C:\Users\Stephen\workspace\UNM computer rename>cmd.exe
OUTPUT>Microsoft Windows [Version 6.1.7601]
OUTPUT>Copyright (c) 2009 Microsoft Corporation. All rights reserved.
OUTPUT>
It looks like it's just spitting back the command line output into the java console, instead of just running the command and opening the cmd line.
I would really appreciate input as I'm in a crunch for time here, thanks!
First, JDK really does not provide pure java API that allows changing computer name. So you have to run script.
Second, if you want to run script using Runtime you have to provide correct command line. So first try to run your script manually. I believe it accepts a least one parameter (the new computer name). So run it from command prompt and see it is working. Then put it to the working directory of your java program and copy/paste the command line into the java code and see that it is working now. if you want you can read STDOUT of your script and/or get its return code. If you do not care about its output just call process.waitFor() and then get the return code.
Be careful with arguments. Windows computer name may contain unicode characters and spaces. If it contains spaces surround it with quotes. Concerning unicode just try. I hope it will not cause problems to you.
You can also use ProcessBuilder class that allows better and more portable arguments passing.
Good luck.
It looks like opencmd.bat is being executed, so assuming your PowerShell script works, is it possible you don't have administrative privileges?
You can also do it elegantly using JNA, I think this would be the target. But if you are rushed for time, don't bother.

Categories

Resources