jdk1.7.0 installation on ubuntu 10.10 - java

I am new to ubuntu 10.10 and am using it as VM. I tried installing jdk 1.7 to run java programs from terminal. I followed the instructions from the link: How to Install Oracle Java on Ubuntu Linux. After installation was complete, i tried to test run a Hello World java program. The program compiled successfully when i did javac Hello.java. However when i tried to run the program using java Hello, it didnt give any output on the terminal and gave me the following:
Unable to launch the application.
Exception:
CouldNotLoadArgumentException[ Could not load file/URL specified: Hello]
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Wrapped Exception
java.io.FileNotFoundException: Hello (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Further i tried checking my version for java using java -version and it gave the following output:
Java(TM) Web Start 10.0.0.147-fcs
Usage: javaws [run-options] <jnlp-file>
javaws [control-options]
where run-options include:
-verbose display additional output
-offline run the application in offline mode
-system run the application from the system cache only
-Xnosplash run without showing a splash screen
-J<option> supply option to the vm
-wait start java process and wait for its exit
control-options include:
-viewer show the cache viewer in the java control panel
-clearcache remove all non-installed applications from the cache
-uninstall remove all applications from the cache
-uninstall <jnlp-file> remove the application from the cache
-import [import-options] <jnlp-file> import the application to the cache
import-options include:
-silent import silently (with no user interface)
-system import application into the system cache
-codebase <url> retrieve resources from the given codebase
-shortcut install shortcuts as if user allowed prompt
-association install associations as if user allowed prompt
I see here that its using javaws when i try to run program using java.
I dont understand why this is happening or what is going wrong. Any help would be very much appreciated. Am just a beginner on Ubuntu.
Thanks in advance!!
Edit 1
Hello.java:
public class Hello
{
public static void main(String... s)
{
System.out.println("Hello World.!!!");
}
}

Your output from java -version give you the ouput from javaws -version.
So this seems to be a linking error in your filesystem.
If you use update-alternatives, you create a symbolic link in your binary-folder (/usr/bin).
Maybe you had some typo while going through the tutorial?
I'm pretty sure it was something like
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_05/bin/javaws" 1 or something like this.
You could try to reenter the "update-alternative" commands.

I am not sure you want 10.10 when 12.04 is available. I installed the Sun/Oracle version and it worked first time. All you have to do is download it, unpack it and add it to your path.
The error message suggests Java is not installed correctly.
I suggest you also install a free IDE like IntelliJ CE. This will make writing, compiling, running and debugging your application much easier.

Related

java.lang.UnsatisfiedLinkError when attempting to run a jar file [duplicate]

I have a small webdriver.io project just for experimenting with it for the first time. I now wanted to add allure reports but when I try to run allure open I get the following exception and I have no idea where I have to look to resolve this:
Starting web server...
2021-05-04 22:06:43.669:INFO::main: Logging initialized #349ms to org.eclipse.jetty.util.log.StdErrLog
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2630)
at java.base/java.lang.Runtime.load0(Runtime.java:768)
at java.base/java.lang.System.load(System.java:1837)
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2648)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
at java.base/java.lang.System.loadLibrary(System.java:1873)
at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1399)
at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1397)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1396)
at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1429)
at java.desktop/java.awt.Desktop.isDesktopSupported(Desktop.java:328)
at io.qameta.allure.Commands.openBrowser(Commands.java:220)
at io.qameta.allure.Commands.open(Commands.java:152)
at io.qameta.allure.CommandLine.run(CommandLine.java:165)
at java.base/java.util.Optional.orElseGet(Optional.java:369)
at io.qameta.allure.CommandLine.main(CommandLine.java:88)
The reports are getting generated just fine. Only when I try to open them I get this error.
I have allure-reporter and allure-commandline installed via npm. I have my project inside a Debian WSL and run chromedriver with VcXsrv X Server in case this might help.
Does anybody have an idea how this error might get resolved or have a hint for what to look for? I hope I gave you enough information. If not, just say what you need. Thanks in advance for your help!
on ubuntu 20.04:
sudo apt install openjdk-11-jdk
As Joakim suggested in this comment here, the headless version was installed. I got the same error with ldd, the library missing.
It's not a good idea to change your question in general, it's better to search first and ask a new one if needed, with all specifics.
This may help you understand the possible cause of the second issue:
Desktop API is not supported on the current platform
I highly recommend to use a plain Ubuntu Linux installation if you want to use Linux, WSL is not the same and has specific issues that you will not encounter in Linux. If a dedicated install is not an option, try to look for generic issues. Expect differences in behavior with shells, docker and graphical related things, because those things are specifically implemented in certain ways for WSL.
[For me it worked]
When you get this kinda error it means in installation of your jdk some of files are missed. To solve this problem act like bellow:
sudo apt install openjdk-[version]-jdk --fix-missing
eg.
sudo apt install openjdk-16-jdk --fix-missing
it means you already installed the jdk but there are some missing files with it. So you can fix it as easy as a pice of cake just by using '--fix-missing'
You likely have some missing downstream libraries.
Run this to find out which ones, then install them.
$ ldd /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so
java.lang.UnsupportedOperationException: The BROWSE action is not supported on the current platform!
at java.desktop/java.awt.Desktop.checkActionSupport(Desktop.java:380)
at java.desktop/java.awt.Desktop.browse(Desktop.java:524)
at io.qameta.allure.Commands.openBrowser(Commands.java:222)
That means WSL doesn't support java.awt.Desktop.browse().
This has been brought up before in Stackoverflow.
See https://stackoverflow.com/a/27881223/775715
/usr/lib/jvm/java-17-openjdk-17.0.4.1.1-1.fc36.x86_64/lib/libawt_xawt.so
This error requires an updat of the jdk.
Download the current update from Oracle support jdk-17_linux-x64_bin.rpm
sudo rpm -ivh jdk-17_linux-x64_bin.rpm
this will install libawt_headless.so and it is working
Operating System deployed to is Fedora36
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-11-openjdk/lib/libawt_xawt.so
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2633)
at java.base/java.lang.Runtime.load0(Runtime.java:768)
at java.base/java.lang.System.load(System.java:1837)
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2445)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2501)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2700)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2651)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
at java.base/java.lang.System.loadLibrary(System.java:1873)
at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1395)
at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1393)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1392)
at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1425)
at java.desktop/java.awt.Insets.<clinit>(Insets.java:89)
at java.desktop/javax.swing.plaf.synth.SynthLookAndFeel.<clinit>(SynthLookAndFeel.java:75)
at snowflake.App.main(App.java:67)
If you get this error on Manjaro Linux when running any Java program (in my case SnowFlake), then you need to install openjdk11-src, jre11-openjdk, jdk11-openjdk

Encountered error setting up plugins for Minecraft Nukkitx server on Raspberry Pi

RPI 2B, running Debian/Jessie, with java version 1.8.0_65.
Downloaded latest nukkitx from https://nukkitx.com.
Followed installation instructions at https://github.com/IntellectualCrafters/PlotSquared/wiki/Installation.
Plugins I have installed:
Plot Squared 18.07.21-aaa7088-2022
FastAsyncWorldEdit 18.07.21-a00345f-1159-20.4.0
DbLib 0.2.3
Error I am encountering:
java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open(Ljava/lang/String;I)V
Stack trace: https://pastebin.com/C3DrUm0Q.
Full server log: https://pastebin.com/2iuvQmbC.
As you can see, it says that PlotSquared has been loaded, but none of the plot commands are available. It just says unknown command when I type it. I have tried several different versions of all of the plugins, and a couple previous versions of nukkitx, all have the same problem. I'm thinking its something about my device, but I'm still pretty new to Linux and am not sure what to try next. Any suggestions would be amazing!
EDIT: I download the driver from https://github.com/xerial/sqlite-jdbc, and added it to the class path when calling the nukkitx jar to start the server. This didn't fix the problem. Here is the .sh file to start the nukkit jar:
#!/bin/sh
echo $USER
java -Xms1G -Xmx1G -cp ".;sqlite-jdbc-3.23.1.jar" -jar nukkit-1.0-SNAPSHOT.jar
I figured it out! For whatever reason, the JbLib sqlite driver apparently wasn't working. The solution was to remove JbLib (jar and folder) from the plugins folder, change the start.sh file (which I created according to the installation instructions) to use a classpath command instead of a jar command, add the xerial sqlite driver to the class path, and specify the Main Nukkit class to execute, like so:
java -classpath nukkit-1.0-SNAPSHOT.jar:sqlite-jdbc-3.23.1.jar cn.nukkit.Nukkit

Jetty 8 Server Startup using only Command Prompt

I am new to using the Jetty server. For starting Jetty v8.1 Using the command prompt, I need to navigate to the jetty-distribution-8.1.16.v20140903 folder and run the command: java -jar start.jar.
In case I don't navigate to the jetty-distribution-8.1.16.v20140903 folder and try to start the command using: java -jar C:\jetty-distribution-8.1.16.v20140903\start.jar then I get an FileNotFoundException :
java.io.FileNotFoundException: No XML configuration files specified in start.con
fig or command line.
at org.eclipse.jetty.start.Main.start(Main.java:502)
at org.eclipse.jetty.start.Main.main(Main.java:96)
Usage: java -jar start.jar [options] [properties] [configs]
java -jar start.jar --help # for more information
What are the files does it looks for while starting the server? Please let me know how to start the jetty server without navigating to the distribution folder.
Edit:
When I tried this command:
java -Djetty.home= C:\jetty-distribution-8.1.16.v20140903 -jar C:\jetty-distribution-8.1.16.v20140903/start.jar
I got the below error:
Caused by: java.lang.ClassNotFoundException: C:\jetty-distribution-8.1.16.v20140
903
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: C:\jetty-distribution-8.1.16.v20140903. Program
will exit.
Please suggest.
Try this:
java -Djetty.home=C:\jetty-distribution-8.1.15.v20140411 -jar C:\jetty-distribution-8.1.15.v20140411/start.jar
According to the Jetty documentation Running Jetty the correct way to start the Jetty server is:
cd $JETTY_HOME
java -jar start.jar
Do you have $JETTY_HOME defined?
If so you can just write a small script, eg called RunJetty or Jetty that contains the above commands. The script could even restore the current directory as well ...
The startup of Jetty 8 is old and now very different than Jetty 9.
Important Note: Jetty 8 is soon EOL, would highly encourage upgrading to Jetty 9 pronto.
For Jetty 8, the ${jetty.home} path is where everything takes place (aka your jetty-distribution directory).
For Jetty 8, it looks for a ${jetty.home}/start.ini and then starts to build up the command line, xml files, properties, start.d OPTIONS declarations, etc to start your environment.
For Jetty 9, this is radically different, there is a clear split between ${jetty.home} the unmodified distribution, and a new ${jetty.base} where you configure for your specific jetty instance. You can even have multiple ${jetty.base} directories for different instances. There is even support for a tiered ${jetty.base} declaration to further separate roles in an organization (ops installs jetty-dist into a common ${jetty.home}, configures a infrastructure ${jetty.base} to handle logging and monitoring, and the application is in its own ${jetty.base}, at which point all 3 are combined to form the configuration that instance uses)

Unable to run threaded java jar file on Mac OS X 10.6.8 with Java 1.7.0.45 using pacifist

I have installed Java 1.7.0_45 on Mac OS X 10.6.8 using Pacifist [http://www.charlessoft.com/] however I am unable to run a jar file which I have downloaded. The jar file is a threaded application.
The error message I am getting is:
java -jar context.jar
2013-10-31 14:14:41.898 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement methodSignatureForSelector: -- trouble ahead
2013-10-31 14:14:41.900 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement doesNotRecognizeSelector: -- abort
Trace/BPT trap
Is there anyway I can run the jar. I have set the JAVA_HOME path properly and java -version is showing 1.7.0_45 as the version.
The same application works properly on Windows Java 1.7.0_45 and also on Linux Java 1.7.
The web search for the solution and the given keywords return very few results and none of them have any specific solution in it. I am new to mac so I am not fully able to understand the issue.
Alternatively, is there anyway I can run Java from folder in Mac like I can do in windows and Linux by just extracting the Java contents and changing the JAVA_HOME. If that is possible then I should be able to run my JAR.
I had kind of same problem while installing an application through jar file, my Java was not detected by the jar application installer,
Over here I see that one of the method is not accessible, could be a same problem. But I am not very sure of it.
make sure you have rt.jar in your JAVA_HOME/jre/lib/ folder
In case you don't have then you are required to have it through the process of creation of symbolic link.
In the command below replace your_java_version with proper version matching your requirement.
sudo mkdir -p /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib
Go into the directory:
cd /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib/
Create symbolic link :
sudo ln -s ../../../Classes/classes.jar rt.jar
Hope this solves your problem.
I get the exact same problem with MacOS 10.6.8 and JDK 7. In order to run the jar I had to use the System JRE which is 1.6.x (In my case I wanted to install Squirrel
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -jar >squirrel-sql-3.6-MACOSX-install.jar

Ant: How to Install a Compiled Program (FOP 1.0)

The version of Ubuntu I use provides FOP 0.95. Its having problems, so I wanted to try the latest version of FOP. I successfully downloaded and built the sources.
Unfortunately, I can't figure out how to install FOP 1.0. The build instructions (https://xmlgraphics.apache.org/fop/1.0/compiling.html) did not cover the topic, and the README does not offer any instructions.
I naively tried ant install --prefix=/usr/local which failed. Ant listed its flags and switches, but did not include an install option. Next, I performed sudo cp ./fop /usr/local/bin, which resulted in the following
$fop -V
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fop/cli/Main
Caused by: java.lang.ClassNotFoundException: org.apache.fop.cli.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.apache.fop.cli.Main. Program will exit.
How does one install a program with Ant?
Jeff
Uncompress the download to a directory.
Add that directory to your path.
export PATH=~/tech/lang/java/fop/fop-1.0/:$PATH
That's it:
Daves-MacBook-Pro:~ Dave$ fop -V
USAGE
fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] <outfile>
[OPTIONS]
-version print FOP version and exit
-d debug mode
-x dump configuration settings
# etc...
Welcome to the world of PATH and environment variables in Java.
The error is being caused because java cannot find the class libraries it requires.
You will find that fop is a script which invokes java with the appropriate parameters for this java application.
You also need to check your java installation and make sure everything is straight.

Categories