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
MAVEN(1)							   User Commands							  MAVEN(1)

NAME
Maven - Creates a link from a jar already installed in /usr/share/maven-repo. SYNOPSIS
mh_linkrepojar [option]... [pom] [link]... DESCRIPTION
Create symlinks from the jar in the Maven repository to any location, usually to a file located in /usr/share/java. Where [pom] is the location of the POM associated with the jar to install. GroupId, artifactId and version will be extracted from this file. [link] is a link to the jar to install, usually there should be a link to usr/share/java/$jar.jar and usr/share/java/$jar-$version.jar to comply with the Java packaging guidelines. Note that there is no need to specify those particular links if the --java-lib option is used. OPTIONS
-h --help: show this text -V --version: show the version -p<package> --package=<package>: package to act on -r<rules> --rules=<rules>: gives the location of the rules file for special properties. Optional, the default location is debian/maven.rules -c<classifier> --classifier=<classifier>: Optional, the classifier for the jar in the Maven repository. Empty by default. -v --verbose: show more information while running -n --no-act: don't actually do anything, just print the results Maven Repo Helper version 1.7.1 January 2012 MAVEN(1)
All times are GMT -4. The time now is 07:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy