Sponsored Content
Top Forums UNIX for Dummies Questions & Answers trying to compile and run java through the terminal Post 302313654 by killesk on Wednesday 6th of May 2009 08:32:49 AM
Old 05-06-2009
trying to compile and run java through the terminal

Hey everybody,

Ok here is my problem. I have this code that that compiles, but when i go to run it it gives me errors.

I stored my simple java class here:
/user/workspace/getMailFromSafeDoc/src

I store my mail.jar file here:
/user/workspace/getMailFromSafeDoc/lib/javaMail/javaMail.jar

In my terminal i go to that folder and i compile it by:
javac -classpath ../lib/javaMail/javaMail.jar javaMail.java

..... this works and products a class file with no errors.

when i go to complile it by:
java javaMail

i get:
Exception in thread "main" java.lang.NoClassDefFoundError:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/NoSuchProviderException
Caused by: java.lang.ClassNotFoundException: javax.mail.NoSuchProviderException
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:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)


When i take out all the try and catch, it works fine.


Here is my code:

Code:
import javax.mail.*;
public class getMail 

{
    
private String userName;
    
private String userPassword;
    
private String mailServer;
    
public getMail(String inputUserName, String inputPassword, String inputMailServer)
    
{
        
    userName = inputUserName;
    
    userPassword = inputPassword;
    
    mailServer =inputMailServer;
    
    processMail(userName, userPassword, mailServer);
    
}
    
    

public static void main(String[] args) 

{
        
// TODO Auto-generated method stub
        
//System.out.println("Hi");
        
getMail getSafedocMail = new getMail("dcm", "dcm01", "mail.safedoc.ie");
    
}
    
    
    


private void printData(String inputString)
    
{   
    System.out.println(inputString);   
}
    
    
    


private void processMail(String inputUserName, String inputPassword, String inputMailServer)
    
{
    
    Session session = null;
    
    Store store = null;
    
    printData("-------------connecting to mail-----------------");
        
    session = Session.getDefaultInstance(System.getProperties(), null);
    

    try 
        
    {
            

        store = session.getStore("pop3");
        
    } 
        
    catch (NoSuchProviderException e) 
    
    {
    
        e.printStackTrace();
    
    }
    
}


Any idea lads?
 

10 More Discussions You Might Find Interesting

1. Programming

compile java with GUI on unix system/putty

is it possible in the first place? if so, how should I go about it? (0 Replies)
Discussion started by: finalight
0 Replies

2. Programming

how can compile cpp code containing references to java classes

hi there is example (on link given below )of such code that contains java class reference in c++ program. http://slackware.cs.utah.edu/pub/slackware/slackware-7.1/docs/Linux-HOWTO/Process-Monitor-HOWTO I am new in linux environment. and not able to compile it. when i compile it through... (1 Reply)
Discussion started by: surinder
1 Replies

3. Solaris

how to compile and run java programs

Hi, I have installed Solaris 10 on a VMware. How to compile a java program as there is no javac in 'bin' directory. Thanks in advance for answers and sorry if the question is soo basic. (3 Replies)
Discussion started by: mayahari
3 Replies

4. HP-UX

Compile .java

How would I go about compiling a .java file into a .class file? (1 Reply)
Discussion started by: Tecron
1 Replies

5. UNIX for Dummies Questions & Answers

Compile & Run Java Code

The java program is a part of speech tagger -> The Stanford NLP (Natural Language Processing) Group The goal is to use this script as part of a webpage to tag parts of speech based on a user-inputted string. I have no idea what to do with the files - I'm a complete *nix noob. I tried running... (4 Replies)
Discussion started by: tguillea
4 Replies

6. Programming

Can someone compile and run a program on AIX 6.1 please?

Hi, I have a program which collects performance data from AIX. It works fine on older releases (< 5.3) but I fail to get data from /proc. I would really appreciate it if someone could compile (using ANSI compat C compiler), run the program (for 30-40 minutes) on AIX 6.1 and send me the... (2 Replies)
Discussion started by: StuBob
2 Replies

7. UNIX for Advanced & Expert Users

java compile and run program help

What is the trick to get a java program to run and compile? I can't even get a basic skeleton to run and compile. What packages do I need? I figured the java-gcj and gcc-java packages was enough. Do I need any other packages? I thought I had to do this and it would work but its not. javac... (1 Reply)
Discussion started by: cokedude
1 Replies

8. Shell Programming and Scripting

Who -u gives different output if run from cron than if run from terminal?

If I run 'who -u' interactively or from a script invoked through bash in a tty on my Ubuntu 12LTS box I get an output like this: testuser pts/0 Dec 9 02:32 . 2163 (host.xx.yy) running the same through cron I get: testuser pts/0 2012-12-09 02:32 00:05 2163... (2 Replies)
Discussion started by: latimer
2 Replies

9. UNIX for Dummies Questions & Answers

How to compile and run java in UNIX?

Hi Im using MobaXterm Unix on my windows XP.I want to compile java in unix.I have installed java to the following path C:\Program Files\Java\jdk1.7.0_09\bin In order to compile the java prog im typing the following command after entering into the bin directory: C:\Program... (2 Replies)
Discussion started by: ak3141
2 Replies

10. Programming

Using basic UNIX commands to make/compile JAVA files

Hello! This is my first post, and I just learned what UNIX was this week. For a JAVA programming class I am taking, I must be able to create a directory in UNIX, use the nano command to create a JAVA program, compile it, and then run it on the command prompt using the java command. For some... (5 Replies)
Discussion started by: UNdvoItX
5 Replies
GIT-CHECK-ATTR(1)						    Git Manual							 GIT-CHECK-ATTR(1)

NAME
git-check-attr - Display gitattributes information SYNOPSIS
git check-attr [-a | --all | attr...] [--] pathname... git check-attr --stdin [-z] [-a | --all | attr...] < <list-of-paths> DESCRIPTION
For every pathname, this command will list if each attribute is unspecified, set, or unset as a gitattribute on that pathname. OPTIONS
-a, --all List all attributes that are associated with the specified paths. If this option is used, then unspecified attributes will not be included in the output. --cached Consider .gitattributes in the index only, ignoring the working tree. --stdin Read file names from stdin instead of from the command-line. -z Only meaningful with --stdin; paths are separated with a NUL character instead of a linefeed character. -- Interpret all preceding arguments as attributes and all following arguments as path names. If none of --stdin, --all, or -- is used, the first argument will be treated as an attribute and the rest of the arguments as pathnames. OUTPUT
The output is of the form: <path> COLON SP <attribute> COLON SP <info> LF <path> is the path of a file being queried, <attribute> is an attribute being queried and <info> can be either: unspecified when the attribute is not defined for the path. unset when the attribute is defined as false. set when the attribute is defined as true. <value> when a value has been assigned to the attribute. EXAMPLES
In the examples, the following .gitattributes file is used: *.java diff=java -crlf myAttr NoMyAttr.java !myAttr README caveat=unspecified o Listing a single attribute: $ git check-attr diff org/example/MyClass.java org/example/MyClass.java: diff: java o Listing multiple attributes for a file: $ git check-attr crlf diff myAttr -- org/example/MyClass.java org/example/MyClass.java: crlf: unset org/example/MyClass.java: diff: java org/example/MyClass.java: myAttr: set o Listing all attributes for a file: $ git check-attr --all -- org/example/MyClass.java org/example/MyClass.java: diff: java org/example/MyClass.java: myAttr: set o Listing an attribute for multiple files: $ git check-attr myAttr -- org/example/MyClass.java org/example/NoMyAttr.java org/example/MyClass.java: myAttr: set org/example/NoMyAttr.java: myAttr: unspecified o Not all values are equally unambiguous: $ git check-attr caveat README README: caveat: unspecified SEE ALSO
gitattributes(5). GIT
Part of the git(1) suite Git 1.7.10.4 11/24/2012 GIT-CHECK-ATTR(1)
All times are GMT -4. The time now is 04:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy