Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Error Message NoClassDefFoundError

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error Message NoClassDefFoundError

    Went through the forum, but did not quite find an error that matched mine.

    The error is as follows: Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils

    Code is really long, so I figured I would start with sharing the error message and see if anyone can point me in the right direction. Seems like I might be missing an external file maybe?

    I do have the commons.io file set in the classpath.

    Any help will be greatly appreciated.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Error Message NoClassDefFoundError

    Can you post the command line you use to start Tomcat?
    What jar file is the org.apache.commons.io.FileUtils class file in?

    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
    Can you copy the lines that follow that line in the stack trace and paste it here so we can see who was doing the calling?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2019
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error Message NoClassDefFoundError

    I am running the program directly from Eclipse.

    The jar file is commons-io-2.6.jar.

    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
    at ProjectSetup.copyNetDir(ProjectSetup.java:665)
    at ProjectSetup.start(ProjectSetup.java:366)
    at ProjectSetup.actionPerformed(ProjectSetup.java:294 )
    at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1967)
    at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2308)
    at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:405)
    at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:262)
    at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:279)
    at java.desktop/java.awt.Component.processMouseEvent(Component.jav a:6632)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponen t.java:3342)
    at java.desktop/java.awt.Component.processEvent(Component.java:639 7)
    at java.desktop/java.awt.Container.processEvent(Container.java:226 3)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.jav a:5008)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.jav a:2321)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:48 40)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4918)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4547)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4488)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.jav a:2307)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2762 )
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:48 40)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:772)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(Access Controller.java:389)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessI mpl.doIntersectionPrivilege(ProtectionDomain.java: 85)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessI mpl.doIntersectionPrivilege(ProtectionDomain.java: 95)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
    at java.base/java.security.AccessController.doPrivileged(Access Controller.java:389)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessI mpl.doIntersectionPrivilege(ProtectionDomain.java: 85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java: 742)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThre ad.java:90)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(B uiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.lo adClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:5 21)
    ... 38 more

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Error Message NoClassDefFoundError

    The jar file is commons-io-2.6.jar.
    Is it on the classpath?

    What is the contents of the commandline when the program is executed?

    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
    at ProjectSetup.copyNetDir(ProjectSetup.java:665)
    at ProjectSetup.start(ProjectSetup.java:366)
    at ProjectSetup.actionPerformed(ProjectSetup.java:294 )
    That stacktrace looks like it is from your program, not the tomcat program. What code is at line 665 in ProjectSetup?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Nov 2019
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error Message NoClassDefFoundError

    This is my code below:

    import javax.swing.*;
    //import javax.swing.event.*;
    import javax.swing.filechooser.*;
    //import javax.swing.text.*;
    //import javax.swing.SwingUtilities;
    //import javax.swing.plaf.nimbus.*;
    //import javax.swing.UIManager.*;
     
    import java.awt.*;
    import java.awt.event.*;
     
    import java.io.*;
    //import java.util.*;
    import java.util.ArrayList;
     
    //used to copy the Marketing directory from the network
    import org.apache.commons.io.*;
     
    //used to open the file browser after creation
    import java.awt.Desktop;
     
     
    public class ProjectSetupConnect implements ActionListener {
     
    	//Main Window Variables
    	private JFrame frame;
     
    	private JTextField txtProject;
    	private JTextField txtEnter;
     
    	private JFileChooser selectFile;
    	private JFileChooser selectSavedFile;
     
    	private JButton btnCreate;
    	private JButton btnBrowse;
     
    	private ButtonGroup bGroup;
     
    	private JLabel lblProject;
    	private JLabel lblEnter;
     
    	private JRadioButton rdbtnProjectFdot;
    	private JRadioButton rdbtnProposalFdot;
    	private JRadioButton rdbtnProposalMarketing;
    	private JRadioButton rdbtnPublic;
     
    	private JMenuBar menuBar;
    	private JMenu menuFile;
    	private JMenuItem menuCreateProj;
    	private JMenuItem menuExit;
     
    	private ImageIcon icon;
     
     
     
     
    	//some final strings for button selection/returning text file names
    	private final String PROJECTFDOT_STR = "project.txt";
    	private final String PROPOSALFDOT_STR = "proposalfdot.txt";
    	private final String PROPOSALMARKETING_STR = "proposalmarketing.txt";
    	private final String PUBLIC_STR = "publicmeeting.txt";
     
    	//final file for the Marketing folder copy operation
    	private final File PROJECT_FILE = new File("Network Directory");
    	private final File MARKETING_FILE = new File("Network Directory");
    	private final File PUBLIC_FILE = new File("Network Directory");
     
     
     
    	//Main variables
    	private static String root;
    	private static String project;
    	private static String dir;
     
    	private static boolean fail = false;
     
    	private boolean editRoot = false;
    	private boolean continueAllError = false;
     
     
     
    	/**
    	 * Launch the application.
    	 */
    	public static void main(String[] args) {
     
    		root = "F:\\Projects";
    		project = "";
    		dir = root + "\\" + project;
     
     
    		EventQueue.invokeLater(new Runnable() {
     
     
    			public void run() {
    				try {
     
    					ProjectSetupConnect window = new ProjectSetupConnect();
    					window.frame.setVisible(true);
     
    				}
     
    				catch (Exception e) {
     
    					e.printStackTrace();
     
    				}
    			}
     
    		});
    	}
     
    	/**
    	 * Create the application.
    	 */
    	public ProjectSetupConnect() {
     
     
     
    		initialize();
     
    	}
     
    	/**
    	 * Initialize the contents of the frame.
    	 */
    	private void initialize() {
     
    		//create icon
    		icon = new ImageIcon("ProjectSetup.png");
     
    		//create the Frame
    		frame = new JFrame("Create a Project");
    		frame.setBounds(100, 100, 450, 300);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.getContentPane().setLayout(null);
    		frame.setIconImage(icon.getImage());
     
    		//create Buttons
    		btnBrowse = new JButton("Browse");
    		btnBrowse.addActionListener(this);
    		btnBrowse.setFont(new Font("Tahoma", Font.BOLD, 11));
    		btnBrowse.setBounds(335, 150, 89, 23);
    		frame.getContentPane().add(btnBrowse);
     
    		btnCreate = new JButton("Create");
    		btnCreate.addActionListener(this);
    		btnCreate.setFont(new Font("Tahoma", Font.BOLD, 11));
    		btnCreate.setBounds(335, 207, 89, 23);
    		frame.getContentPane().add(btnCreate);
     
    		//create Labels and Text fields
    		txtProject = new JTextField(root);
    		txtProject.setBounds(10, 151, 245, 20);
    		frame.getContentPane().add(txtProject);
    		txtProject.setColumns(10);
     
    		lblProject = new JLabel("Project Directory:");
    		lblProject.setFont(new Font("Tahoma", Font.BOLD, 12));
    		lblProject.setBounds(89, 117, 113, 23);
    		frame.getContentPane().add(lblProject);
     
    		txtEnter = new JTextField(project);
    		txtEnter.setBounds(10, 210, 245, 20);
    		frame.getContentPane().add(txtEnter);
    		txtEnter.setColumns(10);
     
    		lblEnter = new JLabel("Enter the project name:");
    		lblEnter.setFont(new Font("Tahoma", Font.BOLD, 12));
    		lblEnter.setBounds(74, 182, 154, 17);
    		frame.getContentPane().add(lblEnter);
     
    		//create Radio buttons
    		rdbtnProjectFdot = new JRadioButton("Project - FDOT Style Folder Structure");
    		rdbtnProjectFdot.addActionListener(this);
    		rdbtnProjectFdot.setFont(new Font("Tahoma", Font.BOLD, 11));
    		rdbtnProjectFdot.setBounds(10, 7, 253, 23);
    		frame.getContentPane().add(rdbtnProjectFdot);
     
    		rdbtnProposalFdot = new JRadioButton("Proposal - FDOT Style Folder Structure");
    		rdbtnProposalFdot.addActionListener(this);
    		rdbtnProposalFdot.setFont(new Font("Tahoma", Font.BOLD, 11));
    		rdbtnProposalFdot.setBounds(10, 33, 253, 23);
    		frame.getContentPane().add(rdbtnProposalFdot);
     
    		rdbtnProposalMarketing = new JRadioButton("Proposal - Marketing Folders Only");
    		rdbtnProposalMarketing.addActionListener(this);
    		rdbtnProposalMarketing.setFont(new Font("Tahoma", Font.BOLD, 11));
    		rdbtnProposalMarketing.setBounds(10, 61, 253, 23);
    		frame.getContentPane().add(rdbtnProposalMarketing);
     
    		rdbtnPublic = new JRadioButton("Public Meetings/Hearings");
    		rdbtnPublic.addActionListener(this);
    		rdbtnPublic.setFont(new Font("Tahoma", Font.BOLD, 11));
    		rdbtnPublic.setBounds(10, 87, 253, 23);
    		frame.getContentPane().add(rdbtnPublic);
     
    		//create File menu
    		menuBar = new JMenuBar();
    		frame.setJMenuBar(menuBar);
     
    		menuFile = new JMenu("File");
    		menuBar.add(menuFile);
     
    		menuCreateProj = new JMenuItem("Create a ProjectSetup shortcut");
    		menuCreateProj.addActionListener(this);
    		menuFile.add(menuCreateProj);
     
    		menuExit = new JMenuItem("Exit");
    		menuExit.addActionListener(this);
    		menuFile.add(menuExit);
     
    		selectFile = new JFileChooser();
    		selectFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    		FileSystemView fsv = FileSystemView.getFileSystemView();
      		selectSavedFile = new JFileChooser(fsv.getRoots()[0]);
     
      		//button group setup
      		bGroup = new ButtonGroup();
      		bGroup.add(rdbtnProjectFdot);
      		bGroup.add(rdbtnProposalFdot);
      		bGroup.add(rdbtnProposalMarketing);
      		bGroup.add(rdbtnPublic);
      		rdbtnProjectFdot.setSelected(true);
     
      		//button action commands
      		rdbtnProjectFdot.setActionCommand(PROJECTFDOT_STR);
      		rdbtnProposalFdot.setActionCommand(PROPOSALFDOT_STR);
      		rdbtnProposalMarketing.setActionCommand(PROPOSALMARKETING_STR);
      		rdbtnPublic.setActionCommand(PUBLIC_STR);
     
    	}
     
    	//run when any button is pressed
    	public void actionPerformed(ActionEvent e) {
     
    		//check if root has changed
    		if(!root.equals(txtProject.getText()))
    			editRoot=true;
     
    		if(e.getSource() == btnCreate) {
     
    			//check for blank project title
    			if(txtEnter.getText() .isEmpty()) {
     
    				JOptionPane.showMessageDialog(null, "Project name is empty");
    				return;
     
    			}
     
    			//update directory variables
    			root = txtProject.getText();
    			project = txtEnter.getText();
    			setDirectory();
     
    			//creates the Option Pane object
    			final JOptionPane optionPane = new JOptionPane("This will create a new project folder at: \n" + dir + "\n" + "Continue?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
     
    			String[] choices = {"Continue", "Cancel"};
     
    			//create message string
    			String message = "This will create a new folder at:\n" + dir + "\n";
     
    			if(bGroup.getSelection().getActionCommand().equals(PROJECTFDOT_STR)) {
     
    				if(!txtProject.getText().contentEquals("Network Drive"))
    					message = message + "Most project folders should be located in F:\\Projects, continue?";
     
    			}
     
    			if(bGroup.getSelection().getActionCommand().equals(PROPOSALMARKETING_STR) || bGroup.getSelection().getActionCommand().equals(PROPOSALFDOT_STR)) {
     
    				if(!txtProject.getText().contentEquals("Network Drive"))
    					message = message + "Most proposal folders should be located in F:\\Proposals, continue?";
     
    			}
     
    			if(bGroup.getSelection().getActionCommand().equals(PUBLIC_STR)) {
     
    				if(!txtProject.getText().equals("Network Path"))
    					message = message + "Most Public Hearing folders should be located in\nNetwork Path, continue?";
     
    				}
     
    			//get the response from the user
    			int response = optionPane.showOptionDialog(frame, message, "Confirm Action", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, "");
     
    			if (response == 0) {
     
    				start();
     
    			}
     
    		}
    		else if(e.getSource() == btnBrowse) {
     
    			int returnVal = selectFile.showOpenDialog(frame);
     
    			if (returnVal == JFileChooser.APPROVE_OPTION) {
     
    				File selectedDir = selectFile.getSelectedFile();
    				txtProject.setText(selectedDir.getAbsolutePath());
     
    			}
     
    		}
     
    		//user selected a project template, check if it should automatically change the root text field
    		else if(e.getSource() == rdbtnProjectFdot && !editRoot) {
     
    			root="Network Drive";
    			txtProject.setText(root);
     
    		}
     
    		//user selected a proposal template, check if it should automatically change the root text field
    		else if((e.getSource() == rdbtnProposalMarketing || e.getSource() == rdbtnProposalFdot) && !editRoot) {
     
    			root="Network Drive";
    			txtProject.setText(root);
     
    		}
     
    		else if (e.getSource() == rdbtnPublic && !editRoot) {
     
    			root="Network Path";
    			txtProject.setText(root);
     
    		}
     
    		else if (e.getSource() == menuExit) {
     
    			System.exit(0);
     
    		}
     
    		else if (e.getSource() == menuCreateProj) {
     
    			createProject();
     
    		}
     
    	}
     
    	public void start() {
     
    		//nothing selected
    		if (bGroup.getSelection() == null) {
     
    			JOptionPane.showMessageDialog(null, "No type selected choose a folder structure to create.");
     
    		}
     
    		//FDOT project selected
    		else if (bGroup.getSelection().getActionCommand().equals(PROJECTFDOT_STR)) {
     
    			try {
     
    				makePCF(root, project);
    				makeDirs(dir, PROJECTFDOT_STR);
    				makePCF(dir, project);
    				copyNetDir(PROJECT_FILE, dir);
    				Desktop.getDesktop().open(new File(dir));
     
    			}
     
    			catch (Exception e) {}
    		}
     
    		//FDOT proposal selected
    		else if (bGroup.getSelection().getActionCommand().equals(PROPOSALFDOT_STR)) {
     
    			try {
     
    				makeDirs(dir, PROPOSALFDOT_STR);
    				makePCF(dir, project);
    				copyNetDir(MARKETING_FILE, dir + "\\Admin\\Marketing");
    				Desktop.getDesktop().open(new File(dir));
    			}
     
    			catch(Exception e) {}
     
    		}
     
     
    		//Marketing proposal only selected
    		else if (bGroup.getSelection().getActionCommand().equals(PROPOSALMARKETING_STR)) {
     
    			try {
     
    				makeDirs(dir, PROPOSALMARKETING_STR);
    				copyNetDir(MARKETING_FILE, dir);
    				Desktop.getDesktop().open(new File(dir));
     
    			}
     
    			catch(Exception e) {}
     
    		}
     
    		//Public meetings selected
    		else if (bGroup.getSelection().getActionCommand().equals(PUBLIC_STR)) {
     
    			try {
     
    				makeDirs(dir, PUBLIC_STR);
    				copyNetDir(PUBLIC_FILE, dir);
    				Desktop.getDesktop().open(new File(dir));
     
    			}
     
    			catch (Exception e) {
     
    				System.out.println("Failed");
    			}
     
    		}
     
    		fail=false;
    		continueAllError=false;
     
    	}
     
     
    	public void setDirectory() {
     
    		dir = root + "\\" + project;
     
    	}
     
    	public void makePCF(String dir, String project) {
     
    		//declare the writer object
    		Writer write;
     
    		File dirFile = new File(dir);
    		if(!dirFile.exists())
    					dirFile.mkdirs();
     
    		if(fail)
    			return;
     
    		try{
     
    			//create the writer object, assign the file name
    			write = new FileWriter(new File(dir + "\\" + project + ".pcf"));
     
    			//write the file
    			write.write("#======================================================================\n");
    			write.write("# Project Configuration File - $Revision: 1.3 $\n");
    			write.write("#======================================================================\n\n");
    			write.write("_USTN_PROJECTDESCR = General Description \n\n");
    			write.write("#----------------------------------------------------------------------\n");
    			write.write("#  Set search paths.\n");
    			write.write("#----------------------------------------------------------------------\n");
    			write.write("MS_DEF			< $(_USTN_PROJECTDATA)dgn/\n");
    			write.write("MS_CELL			< $(_USTN_PROJECTDATA)cell/\n");
    			write.write("MS_CELLOUT		= $(_USTN_PROJECTDATA)cell/\n");
    			write.write("MS_CELLLIST		< $(_USTN_PROJECTDATA)cell/*.cel\n");
    			write.write("MS_CELLSELECTORDIR  	= $(_USTN_PROJECTDATA)cell/\n");
    			write.write("MS_SEEDFILES	    	> $(_USTN_PROJECTDATA)seed/\n");
    			write.write("MS_SYMBRSRC		> $(_USTN_PROJECTDATA)symb/*.rsc\n");
    			write.write("MS_SETTINGSDIR      	< $(_USTN_PROJECTDATA)data/\n");
    			write.write("MS_SETTINGSOUTDIR   	= $(_USTN_PROJECTDATA)data/\n\n");
     
    			//the real financial data is not needed (?)
    			write.write("#  Filler finantial number\n");
    			write.write("FDOT_FIN          = 999999-9-99-99");
     
    			//close the file to finalize the .pcf file
    			write.close();
    		}
    		catch(Exception e){
    			if(!continueAllError){
    				String[] choices = {"Continue", "Continue for all errors", "Cancel"};
     
    				String message = "Error creating PCF file at:\n" + dir + "\\" + project + ".pcf" + "\n Check your permissions for this folder and do not include special characters in the project name";
     
    				int response = JOptionPane.showOptionDialog(frame, message, "Error", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, "");
     
    				if(response == 0){//continue button
    					//do nothing?
    				}
    				else if(response == 1){//continue all button
    					continueAllError=true;
    				}
    				else{//cancel button
    					fail=true;
    				}
    			}
    		}
    	}
     
    	public void makeDirs(String dir, String textfile) throws Exception {
     
    		//check if there was an error
    		boolean error=false;
     
    		//setup the file reader
    		InputStream is = getClass().getResourceAsStream(textfile);
    		InputStreamReader isr = new InputStreamReader(is);
    		BufferedReader in = new BufferedReader(isr);
     
    		String input;
     
    		//ArrayList that stores the current directory structure to write to
    		ArrayList<String> struct = new ArrayList<String>();
     
    		while(((input = in.readLine()) != null) && !fail){
    			//Check for blank lines and comments
    			if(input.length()>0 && !(input.substring(0,1).equals("#"))){
    				//find how deep the current folder is in the directory
    				int markers = countMarkers(input);
     
    				//the current directory is correct
    				if(markers >= struct.size()){
    					struct.add(removeMarkers(input));
    					error=!writeDir(struct);
    				}
     
    				//the directory has moved on, needs to erase the old sub-directories from the array
    				else{
    					//remove top level directories that don't apply
    					while(markers < struct.size())
    						struct.remove(struct.size()-1);
     
    					//create
    					struct.add(removeMarkers(input));
    					error=!writeDir(struct);
    				}
    			}
    			if(error){
    				//check if user has selected not to get an error
    				if(!continueAllError){
    					//check if user wants to continue
    					if(directoryError(struct)){
    						fail=true;
    					}
    				}
    			}
    		}
     
    		in.close();
    		isr.close();
    		is.close();
     
     
    	}
     
    	//gets the text file with directory info
    	public static String getFile(ButtonGroup bg) {
     
    		return bg.getSelection().getActionCommand();
     
    	}
     
    	//writes the actual directories
    	public static boolean writeDir(ArrayList<String> struct) {
     
    		String folder = dir;
     
    		//loop through the array and build the string
    		for (int i = 0; i < struct.size(); i++)
    				folder = folder + "\\" + struct.get(i);
     
    		//create the actual directory
    		return (new File (folder)).mkdirs();
     
    	}
     
    	//finds how deep the current directory is
    	public static int countMarkers(String input) {
     
    		int counter = 0;
    		boolean done = false;
     
    		//loop until no ">" are left in the input string
    		while(!done) {
     
    			if(input.substring(0, 1).contentEquals(">")) {
     
    				//remove the ">" and count it
    				input = input.substring(1);
    				counter++;
     
    			}
     
    			//end - there are no more ">" characters
    			else
    				done = true;
    		}
     
    		return counter;
    	}
     
    	//formats the current line sans the ">" markers
    	public static String removeMarkers(String input) {
     
    		if(input.substring(0, 1).contentEquals(">"))
    			return removeMarkers(input.substring(1));
    		else
    			return input;
     
    	}
     
    	//gives a window showing where the program failed
    	public boolean directoryError(ArrayList<String> struct) {
     
    		String folder = dir;
     
    		//loop through the array and build the string
    		for(int i = 0; i < struct.size(); i++)
    			folder = folder + "\\" + struct.get(i);
     
    		String[] choices = {"Continue", "Continue for all errors", "Cancel"};
    		String message = "Error creating directory at: \n" + folder;
     
    		//add specific error message
    		if ((new File(folder)).exists()) {
     
    			message = message + "\nThis folder already exists, continue?";
     
    		}
     
    		else {
     
    			message = message + "\n Check your permissions for this folder and do not include special characters in the project name. Continue?";
     
    		}
     
    		int response = JOptionPane.showOptionDialog(frame, message, "Error", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, "");
     
    		if (response == 0) {
     
    			return false;
     
    		}
     
    		if (response == 1) {
     
    			continueAllError = true;
    			return false;
     
    		}
     
    		else {
     
    			return true;
     
    		}
    	}
     
    	//Copy Network Directory
    	public void copyNetDir (File source, String dir) {
     
    		File dest = new File(dir);
     
    		try {
     
    			dest.mkdirs();
    			FileUtils.copyDirectory(source, dest, false);  //Line 665
     
    		}
    		catch (IOException e) {
     
    		}
    	}
     
    	public void createProject() {
     
    		boolean cantWrite = false;
    		File dest;
     
    		//Source shortcut link to copy
    		File source = new File ("Network Directory");
     
    		//find the operation system
    		String os = System.getProperty("os.name");
     
    		if (os.equalsIgnoreCase("Windows 10") || os.equalsIgnoreCase("Windows 8") || os.equalsIgnoreCase("Windows 7")) {
     
    			dest = new File("Local Path");
     
    			if (dest.canWrite()){
     
    				//switch back to absolute path because FileUtils is weird
    				dest = new File("Local Path");
     
        			try {
     
        			FileUtils.copyFile(source, dest, false);
     
        			}
     
        			catch(IOException i){JOptionPane.showMessageDialog(null,i);}
     
    			}
     
    			else {
     
    				cantWrite=true;
     
    			}
    		}
     
    		else {
     
    			cantWrite=true;
     
    		}
     
    		if (cantWrite) {
     
    			selectSavedFile.setSelectedFile(new File("ProjectSetup.lnk"));
    			int returnVal = selectSavedFile.showSaveDialog(frame);
     
    			if (returnVal == JFileChooser.APPROVE_OPTION) {
     
    				dest = selectSavedFile.getSelectedFile();
     
    				try {
     
    					FileUtils.copyFile(source, dest, false);
     
    				}
     
    				catch (IOException i) {JOptionPane.showMessageDialog(null,  i);}
     
    			}
    		}
    	}
    }

    --- Update ---

    My layout is as follows:

    ProjectSetupConnect
    >src
    >>default package
    >>>ProjectSetupConnect.java
    >>org.apache.commons.io
    >>More commons.io
    >>.txt files
    >>ProjectSetup.png
    >JRE System Library
    >Referenced Libraries
    >>Commons-io-2.6.jar
    Last edited by Tomcat1208; November 15th, 2019 at 11:38 AM.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Error Message NoClassDefFoundError

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.

    Where is the code for the ProjectSetup class? What is on line 665 in that class?

    What is the command line when you execute the program? Is the jar file referenced in that commandline?

    I have no idea what the purpose of the files/folders shown in "My layout" or how they are used by your IDE.

    Try executing the program in a command prompt using the java command with the -cp option and your classname.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Nov 2019
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error Message NoClassDefFoundError

    Line 294
    start();

    Line 366
    copyNetDir(MARKETING_FILE, dir);

    Line 665
    FileUtils.copyDirectory(source, dest, false);

    ProjectSetup Class is actually the ProjectSetupConnect class

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Error Message NoClassDefFoundError

    ProjectSetup Class is actually the ProjectSetupConnect class

    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
    at ProjectSetup.copyNetDir(ProjectSetup.java:665)
    at ProjectSetup.start(ProjectSetup.java:366)
    at ProjectSetup.actionPerformed(ProjectSetup.java:294 )
    Why does the error message say otherwise?


    What about the contents of the commandline from when the program is executed that shows what is on the classpath?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. I keep getting an error message but I don't know how to fix this!
    By mpagudelo in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 12th, 2013, 01:56 AM
  2. [SOLVED] Getting error message and can not figure it out.
    By GoPredsGo in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 10th, 2013, 04:33 AM
  3. Need help with error message!!
    By Rick Sebastian in forum What's Wrong With My Code?
    Replies: 14
    Last Post: March 25th, 2013, 10:24 AM
  4. How to display error message box
    By jasonxman in forum What's Wrong With My Code?
    Replies: 11
    Last Post: August 21st, 2011, 02:47 PM
  5. help with a error message
    By JavaNoob82 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 23rd, 2010, 02:56 PM