DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD Ports and Packages

FreeBSD Ports and Packages Installation and upgrading of ports and packages on FreeBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 9th July 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default How to java on FreeBSD?

Test.java
Code:
import java.lang.reflect.Array;
class Test
{
        public static void main( String argv[] )
        {
                System.out.println( "Arguments:" );
                int i = 0;
                while( i < Array.getLength(argv) )
                {
                        System.out.println( argv[i] );
                        i++;
                }
        }
}
so how to compile ?

Code:
# java Test argument1 argument2 argument3
Exception in thread "main" java.lang.NoClassDefFoundError: Test
Why?
Reply With Quote
  #2   (View Single Post)  
Old 9th July 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

A quick google search seems to indicate that the CLASSPATH environment variable is unset or set improperly.

Java lives in /usr/local/jdk-<version> or /usr/local/diablo-jdk-<version>, depending on which version you installed.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #3   (View Single Post)  
Old 9th July 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default

still can't get it to work, even with setting CLASSPATH, still same old thing

Code:
#java hello
Exception in thread "main" java.lang.NoClassDefFoundError: hello
Reply With Quote
  #4   (View Single Post)  
Old 9th July 2008
kazcor kazcor is offline
Real Name: Registreed Usre
Port Guard
 
Join Date: May 2008
Location: bliner, erg
Posts: 20
Default

Quote:
so how to compile ?
Regarding this question - I hope I'm wrong, but you did this before?
Code:
javac Test.java
Reply With Quote
  #5   (View Single Post)  
Old 9th July 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default

Yes, i did,
# javac Test.java
everything was OK
but them, when i run java Test
Or same with Hello progrram....
I got that dam error

P.S. sorry, i'm in bad mood, i was searching for dam tzupdate....... (finally found it)
Reply With Quote
  #6   (View Single Post)  
Old 9th July 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

Quote:
Originally Posted by killasmurf View Post
still can't get it to work, even with setting CLASSPATH, still same old thing

Code:
#java hello
Exception in thread "main" java.lang.NoClassDefFoundError: hello
Well, what did you set the contents of CLASSPATH to? Are you sure it's set properly?
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #7   (View Single Post)  
Old 9th July 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default

Quote:
Originally Posted by Carpetsmoker View Post
Well, what did you set the contents of CLASSPATH to? Are you sure it's set properly?
I tried multiple versions.....
I use csh, so i tried:

setenv CLASSPATH /usr/local/jdk1.5.0
setenv CLASSPATH /usr/local/jdk1.5.0/bin
setenv CLASSPATH "/usr/local/jdk1.5.0/bin;/usr/local/jdk1.5.0/jre......."

and some more....
Now i'm compiling jdk1.6
maybe that will work
Reply With Quote
  #8   (View Single Post)  
Old 9th July 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

From http://java.sun.com/j2se/1.3/docs/to...classpath.html

Quote:
Class paths to the .jar, .zip or .class files. Each classpath should end with a filename or directory depending on what you are setting the class path to:
For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file.
For .class files in an unnamed package, the class path ends with the directory that contains the .class files.
For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name).

Multiple path entries are separated by semi-colons. With the set command, it's important to omit spaces from around the equals sign (=).

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.

Classpath entries that are neither a directory nor an archive (.zip or .jar file) are ignored.
I don't have Java installed right now, but I think it should be something like /usr/local/jdk1.5.0/Classes/ ...
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #9   (View Single Post)  
Old 9th July 2008
adamk adamk is offline
Spam Deminer
 
Join Date: May 2008
Posts: 250
Default

Your CLASSPATH should be set to the full path of the jar files containing the necessary classes, or the directory the .class files are in.
Reply With Quote
Old 9th July 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default

/usr/local/jdk1.5.0
Code:
# ls
COPYRIGHT
README.html
demo/
jre/
man/
src.zip
LICENSE
bin/
include/
lib/
sample/
Reply With Quote
Old 9th July 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

Sjeez man, show some initiative, search around in the Java directory, search the internet...
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
Old 9th July 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default

I'm doing that.....


Also tried several options with
java -classpath
but no progress

Last edited by graudeejs; 9th July 2008 at 06:23 PM.
Reply With Quote
Old 9th July 2008
adamk adamk is offline
Spam Deminer
 
Join Date: May 2008
Posts: 250
Default

Well do you know what class you need and where it's located on your system?

Adam
Reply With Quote
Old 9th July 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default

sorry for my noobish noobishness, i found what the hell was wrong... for most part it was program.....
lol


everything worked using
java -classpath . hello


But interesting thing is that example form books CD doesn't compile with javac...... (i might know why)


Wonder if complex programs will work.....

Last edited by graudeejs; 9th July 2008 at 06:53 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java and AI-programming idefix Programming 4 7th February 2009 01:41 PM
FreeBSD 7 and Java? Atazoth FreeBSD General 3 10th September 2008 10:38 PM
java compiler bsdnewbie999 OpenBSD Packages and Ports 8 9th August 2008 12:18 PM
Java JDK Oko OpenBSD Packages and Ports 10 13th July 2008 07:39 PM
Odd Java Issue DrJ FreeBSD Ports and Packages 0 12th May 2008 12:35 AM


All times are GMT. The time now is 05:22 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick