har lige installeret suns java i /home/kristian/java/j2sdk1.4.2_10
nu er porblemet imidlertid at når jeg skal compile / køre en fil skal det gøres med kommandoen /home/kristian/java/j2sdk1.4.2_10/bin/javac fil.java og /home/kristian/java/j2sdk1.4.2_10/bin/java fil
Øverst i min .bash_profile er følgende linie indsat: PATH=~/bin:"${PATH}":/home/kristian/java/j2sdk1.4.2_10/bin
Update: når jeg adder linien "export PATH=~/bin:/home/kristian/java/j2sdk1.4.2_10/bin" øverst i min .bash_profile kan jeg bruge java og javac kommandoerne, hvis jeg først skriver source .bash_profile
Når jeg istedet adder linien "export PATH=$PATH:~/bin:/home/kristian/java/j2sdk1.4.2_10/bin" kan jeg ikke bruge nogen af delene
/etc/profile: ---------------------------------------- # /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "`id -u`" -eq 0 ]; then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11" else PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games" fi
if [ "$PS1" ]; then if [ "$BASH" ]; then PS1='\u@\h:\w\$ ' if [ -f /etc/bash.bashrc ]; then . /etc/bash.bashrc fi else if [ "`id -u`" -eq 0 ]; then PS1='# ' else PS1='$ ' fi fi fi
.bash_profile: --------------------------------------- export PATH=$PATH:~/bin:/home/kristian/java/j2sdk1.4.2_10/bin # ~/.bash_profile: executed by bash(1) for login shells. # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package.
# the default umask is set in /etc/login.defs #umask 022
# include .bashrc if it exists if [ -f ~/.bashrc ]; then . ~/.bashrc fi
if [ "`id -u`" -eq 0 ]; then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11" else PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games:/home/kristian/java/j2sdk1.4.2_10/bin" fi
kristian@ubuntu:~/Desktop/sensorv2$ java SensorDriver Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit at java.awt.Toolkit.getDefaultToolkit() (/usr/lib/libgcj.so.6.0.0) at java.awt.EventQueue.invokeLater(java.lang.Runnable) (/usr/lib/libgcj.so.6.0.0) at javax.swing.SwingUtilities.invokeLater(java.lang.Runnable) (/usr/lib/libgcj.so.6.0.0) at javax.swing.RepaintManager.addInvalidComponent(javax.swing.JComponent) (/usr/lib/libgcj.so.6.0.0) at javax.swing.JComponent.revalidate() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JComponent.setOpaque(boolean) (/usr/lib/libgcj.so.6.0.0) at javax.swing.JPanel.JPanel(java.awt.LayoutManager, boolean) (/usr/lib/libgcj.so.6.0.0) at javax.swing.JPanel.JPanel() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JRootPane.createGlassPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JRootPane.getGlassPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JRootPane.JRootPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JFrame.createRootPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JFrame.getRootPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JFrame.frameInit() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JFrame.JFrame() (/usr/lib/libgcj.so.6.0.0) at SensorFrame.SensorFrame() (Unknown Source) at SensorDriver.main(java.lang.String[]) (Unknown Source) at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0) at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0) Caused by: java.lang.ClassNotFoundException: gnu.java.awt.peer.gtk.GtkToolkit not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}} at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0) at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.6.0.0) at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0) at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0) at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.6.0.0) at java.awt.Toolkit.getDefaultToolkit() (/usr/lib/libgcj.so.6.0.0) ...18 more
# ~/.bash_profile: executed by bash(1) for login shells. # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package.
# the default umask is set in /etc/login.defs #umask 022
Du må altså være mere precis i din beskrivelse.. er vi tilbage hvor echo $PATH ikke i indeholder /home/kristian/java/j2sdk1.4.2_10/bin eller der det det stacktrace du får?
Men som jeg også sagde
/home/kristian/java/j2sdk1.4.2_10/bin skal være før den orginale PATH
vi er tilbage til punktet hvor det eneste sted jeg har sat PATH er i .bash_profile, hvor der står export PATH=/home/kristian/java/j2sdk1.4.2_10/bin:~/bin:$PATH
resultatet af en java kommando er:
kristian@ubuntu:~/Desktop/sensorv2$ java SensorDriver Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit at java.awt.Toolkit.getDefaultToolkit() (/usr/lib/libgcj.so.6.0.0) at java.awt.EventQueue.invokeLater(java.lang.Runnable) (/usr/lib/libgcj.so.6.0.0) at javax.swing.SwingUtilities.invokeLater(java.lang.Runnable) (/usr/lib/libgcj.so.6.0.0) at javax.swing.RepaintManager.addInvalidComponent(javax.swing.JComponent) (/usr/lib/libgcj.so.6.0.0) at javax.swing.JComponent.revalidate() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JComponent.setOpaque(boolean) (/usr/lib/libgcj.so.6.0.0) at javax.swing.JPanel.JPanel(java.awt.LayoutManager, boolean) (/usr/lib/libgcj.so.6.0.0) at javax.swing.JPanel.JPanel() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JRootPane.createGlassPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JRootPane.getGlassPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JRootPane.JRootPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JFrame.createRootPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JFrame.getRootPane() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JFrame.frameInit() (/usr/lib/libgcj.so.6.0.0) at javax.swing.JFrame.JFrame() (/usr/lib/libgcj.so.6.0.0) at SensorFrame.SensorFrame() (Unknown Source) at SensorDriver.main(java.lang.String[]) (Unknown Source) at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0) at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0) Caused by: java.lang.ClassNotFoundException: gnu.java.awt.peer.gtk.GtkToolkit not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}} at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0) at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.6.0.0) at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0) at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0) at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.6.0.0) at java.awt.Toolkit.getDefaultToolkit() (/usr/lib/libgcj.so.6.0.0) ...18 more
Ja /home/kristian/java/j2sdk1.4.2_10/bin er jo ikke i PATH mere.
husker du at logge ud og ind af shell hver gang du ændrer?
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.