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 4 of 4

Thread: Java won't compile

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java won't compile

    I know nothing of Java, however, I've got a class that demands it, and I'm stuck.

    I got this code by using Visual Paradigm to convert this from UML to code. I changed what I could based on what we've learned in class, but it won't compile. It is supposed to compile but not execute. Any feedback is greatly appreciated.

    I think next week we move on to XML, thank goodness.
    Attached Files Attached Files


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

    Default Re: Java won't compile

    Please copy the full text of the error messages and paste it here.
    Also paste the code here and be sure to wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java won't compile

    OK. Here's the code. I'll put the errors in another post.

    Account.java
     
    import Periodical.Asset;
     
    public class Account {
    	private final int _MAX_ASSETS = 10;
    	private String _id;
    	private String _name;
    	public Asset _assets;
     
    	public Account(String aInitId, String aInitName) {
     
    	}
     
    	public String getName() {
    		return 0;
    	}
     
    	public String getId() {
     
    	}
     
    	public boolean addAsset(Asset aNewAsset) {
     
    	}
     
    	public boolean removeAsset(Asset aAsset) {
     
    	}
     
    	public Asset[] getAssets() {
     
    	}
     
    	public class Asset {
    		public Account _assets;
    	}
    }

    AccountImporter.java
    import LibraryInterface.AccountManager;
     
    public class AccountImporter {
     
    	public void loadAccountsFromFile(String aFilepath, AccountManager aAccountManager) {
     
    	}
    }
    public class Account {
     
    	public Account(String aInitId, String aInitName) {
     
    	}
    }
    public class AccountManager {
     
    	public void addAcount(Account aNewAccount) {
     
    	}
    }
    }

    AccountManager.java
    import LibraryInterface.AccountManager;
     
    public class AccountImporter {
     
    	public void loadAccountsFromFile(String aFilepath, AccountManager aAccountManager) {
     
    	}
    }
    public class Account {
     
    	public Account(String aInitId, String aInitName) {
     
    	}
    }
    public class AccountManager {
     
    	public void addAcount(Account aNewAccount) {
     
    	}
    }
    }

    Asset.java
    public class Asset {
    	private String type;
    	private String id;
    	private String name;
    	public Account account;
     
    	public Asset(String aInitId, String aInitName, String aInitType) {
     
    	}
     
    	public boolean checkOut(Account aAccount) {
     
    	}
     
    	public void checkIn() {
     
    	}
     
    	public String getName() {
    		return 0;
    	}
     
    	public String getId() {
    		return 0;
    	}
     
    	public String getType() {
    		return 0;
    	}
     
    	public Account getAccount() {
    		return 0;
    	}
     
    	public String toString() {
     
    	}
     
    	protected boolean linkAccount(Account aAccount) {
     
    	}
     
    	protected void unlinkAccount() {
     
    	}
    }
    public class Account {
    	public Asset _account;
     
    	public boolean addAsset(Asset aNewAsset) {
     
    	}
     
    	public boolean removeAsset(Asset aAsset) {
     
    	}
    }

    AssetImporter.java
    public class AssetImporter {
     
    	public void loadAssetFromFile(String aFilepath, Object aAssetManager) {
     
    	}
    }
    import Account.Asset;
     
    public class AssetManager {
     
    	public void addAsset(Asset aNewAsset) {
     
    	}
    }

    AssetManager.java
     
    import LibraryInterface.Asset;
    import LibraryInterface.Account;
     
    public class AssetManager {
    	private final int _MAX_ASSETS = 50;
    	public Asset _assets;
     
    	public AssetManager() {
     
    	}
     
    	public boolean addAsset(Asset aNewAsset) {
     
    	}
     
    	public Asset[] findAvailableAssetsByName(String aSearchString) {
     
    	}
    }
     
    public class Asset {
    	public AssetManager _assets;
     
    	public String getName() {
     
    	}
     
    	public Account getAccount() {
     
    	}
    }

    Book.java
    import Asset.Account;
     
    public class Book extends Asset {
    	private final String _TYPE = "book";
    	private boolean isAvailable;
     
    	public Book(String aInitId, String aInitName) {
     
    	}
     
    	public boolean checkOut(Account aNewAccount) {
     
    	}
     
    	public void checkIn() {
     
    	}
    }
     
    public class Asset {
     
    	public Asset(String aInitId, String aInitName, String aInitType) {
     
    	}
     
    	public String getName() {
     
    	}
     
    	public String getId() {
     
    	}
     
    	public String getType() {
     
    	}
     
    	public Account getAccount() {
     
    	}
     
    	protected void linkAccount(Account aAccount) {
     
    	}
     
    	public String toString() {
     
    	}
     
    	protected void unlinkAccount() {
     
    	}
    }

    LibraryAssetManager.java
    public class LibraryAssetManager {
    	public LibraryInterface _libraryInterface;
    	public AssetManager _assetManager;
    	public AccountManager _accountManager;
     
    	public LibraryAssetManager() {
     
    	}
     
    	public void loadAssetFromFile(String aFilepath) {
     
    	}
     
    	public void loadAccountsFromFile(String aFilepath) {
     
    	}
    }
    public class AccountImporter {
     
    	public void importAccountsFromFile(String aFilepath, AccountManager aAccountManager) {
     
    	}
     
    }
    public class AccountManager {
    	public LibraryAssetManager _accountManager;
     
    	public AccountManager() {
     
    	}
    }
    public class AssetImporter {
     
    	public void importAssetsFromFile(String aFilepath, AssetManger aAssetManger) {
     
    	}
    }
    public class AssetManager {
    	public LibraryAssetManager _assetManager;
     
    	public AssetManager() {
     
    	}
    }
    public class LibraryInterface {
    	public LibraryAssetManager _libraryInterface;
     
    	public LibraryInterface() {
     
    	}
     
    	public void refreshAssets() {
     
    	}
     
    	public void refreshAccountAssets() {
     
    	}
     
    	public void setAssetManager(AssetManager aNewAssetManager) {
     
    	}
     
    	public void setAccountManager(AccountManager aNewAccountManager) {
     
    	}
    }

    LibraryInterface.java
    import LibraryAssetManager.AssetManager;
    import LibraryAssetManager.AccountManager;
     
    public class LibraryInterface {
    	public AssetManager _assetManager;
    	public AccountManager _accountManager;
    	public Account _currentAccount;
    	public Asset _currentAssets;
     
    	public LibraryInterface() {
     
    	}
     
    	public void refreshAssets() {
     
    	}
     
    	public void refreshAccountAssets() {
     
    	}
     
    	public void setAssetManager(AssetManager aNewAssetManager) {
     
    	}
     
    	public void setAccountManager(AccountManager aNewAccountManager) {
     
    	}
    }
    public class Account {
    	public LibraryInterface _currentAccount;
     
    	public String getName() {
     
    	}
     
    	public Asset[] getAssets() {
     
    	}
    }
    public class AccountManager {
    	public LibraryInterface _accountManager;
     
    	public Account findAccountById(String aId) {
     
    	}
    }
    public class Asset {
    	public LibraryInterface _currentAssets;
     
    	public void checkIn() {
     
    	}
     
    	public void checkOut(Account aAccount) {
     
    	}
     
    	public String toString() {
     
    	}
    }
    public class AssetManager extends LibraryInterface {
    	public LibraryInterface _assetManager;
     
    	public Asset[] findAvailableAssetsByName(String aSearchString) {
     
    	}
    }

    Periodical.java
    import LibraryAssetManager.AssetManager;
    import LibraryAssetManager.AccountManager;
     
    public class LibraryInterface {
    	public AssetManager _assetManager;
    	public AccountManager _accountManager;
    	public Account _currentAccount;
    	public Asset _currentAssets;
     
    	public LibraryInterface() {
     
    	}
     
    	public void refreshAssets() {
     
    	}
     
    	public void refreshAccountAssets() {
     
    	}
     
    	public void setAssetManager(AssetManager aNewAssetManager) {
     
    	}
     
    	public void setAccountManager(AccountManager aNewAccountManager) {
     
    	}
    }
    public class Account {
    	public LibraryInterface _currentAccount;
     
    	public String getName() {
     
    	}
     
    	public Asset[] getAssets() {
     
    	}
    }
    public class AccountManager {
    	public LibraryInterface _accountManager;
     
    	public Account findAccountById(String aId) {
     
    	}
    }
    public class Asset {
    	public LibraryInterface _currentAssets;
     
    	public void checkIn() {
     
    	}
     
    	public void checkOut(Account aAccount) {
     
    	}
     
    	public String toString() {
     
    	}
    }
    public class AssetManager extends LibraryInterface {
    	public LibraryInterface _assetManager;
     
    	public Asset[] findAvailableAssetsByName(String aSearchString) {
     
    	}
    }


    --- Update ---

    Here's the errors:

    javac Account.java
    Account.java:14: error: package Periodical does not exist
    import Periodical.Asset;
                     ^
    Account.java:27: error: incompatible types
    		return 0;
    		       ^
      required: String
      found:    int
    2 errors

     
    javac AccountImporter.java
    AccountImporter.java:34: error: class, interface, or enum expected
    }
    ^
    1 error

    javac AccountManager.java
    AccountManager.java:16: error: class AccountManger is public, should be declared in a file named AccountManger.java
    public class AccountManger {
           ^
    AccountManager.java:32: error: class Account is public, should be declared in a file named Account.java
    public class Account {
           ^
    AccountManager.java:14: error: package Asset does not exist
    import Asset.Account;
                ^
    3 errors

     
    javac Asset.java
    Asset.java:59: error: class Account is public, should be declared in a file named Account.java
    public class Account {
           ^
    Asset.java:32: error: incompatible types
    		return 0;
    		       ^
      required: String
      found:    int
    Asset.java:36: error: incompatible types
    		return 0;
    		       ^
      required: String
      found:    int
    Asset.java:40: error: incompatible types
    		return 0;
    		       ^
      required: String
      found:    int
    Asset.java:44: error: incompatible types
    		return 0;
    		       ^
      required: Account
      found:    int
    5 errors

    javac AssetImporter.java
    AssetImporter.java:20: error: class, interface, or enum expected
    import Account.Asset;
    ^
    1 error

    javac AssetManager.java
    AssetManager.java:33: error: class Asset is public, should be declared in a file named Asset.java
    public class Asset {
           ^
    AssetManager.java:13: error: package LibraryInterface does not exist
    import LibraryInterface.Asset;
                           ^
    AssetManager.java:14: error: package LibraryInterface does not exist
    import LibraryInterface.Account;
                           ^
    ./Account.java:14: error: package Periodical does not exist
    import Periodical.Asset;
                     ^
    ./Account.java:27: error: incompatible types
    		return 0;
    		       ^
      required: String
      found:    int
    5 errors

     
    javac LibraryAssetManager.java
    LibraryAssetManager.java:31: error: class AccountImporter is public, should be declared in a file named AccountImporter.java
    public class AccountImporter {
           ^
    LibraryAssetManager.java:38: error: class AccountManager is public, should be declared in a file named AccountManager.java
    public class AccountManager {
           ^
    LibraryAssetManager.java:45: error: class AssetImporter is public, should be declared in a file named AssetImporter.java
    public class AssetImporter {
           ^
    LibraryAssetManager.java:51: error: class AssetManager is public, should be declared in a file named AssetManager.java
    public class AssetManager {
           ^
    LibraryAssetManager.java:58: error: class LibraryInterface is public, should be declared in a file named LibraryInterface.java
    public class LibraryInterface {
           ^
    LibraryAssetManager.java:47: error: cannot find symbol
    	public void importAssetsFromFile(String aFilepath, AssetManger aAssetManger) {
    	                                                   ^
      symbol:   class AssetManger
      location: class AssetImporter
    6 errors

     
    javac LibraryInterface.java
    LibraryInterface.java:42: error: class Account is public, should be declared in a file named Account.java
    public class Account {
           ^
    LibraryInterface.java:53: error: class AccountManager is public, should be declared in a file named AccountManager.java
    public class AccountManager {
           ^
    LibraryInterface.java:60: error: class Asset is public, should be declared in a file named Asset.java
    public class Asset {
           ^
    LibraryInterface.java:75: error: class AssetManager is public, should be declared in a file named AssetManager.java
    public class AssetManager extends LibraryInterface {
           ^
    LibraryInterface.java:13: error: package LibraryAssetManager does not exist
    import LibraryAssetManager.AssetManager;
                              ^
    LibraryInterface.java:14: error: package LibraryAssetManager does not exist
    import LibraryAssetManager.AccountManager;
                              ^
    6 errors

    javac Periodical.java
    Periodical.java:31: error: class Asset is public, should be declared in a file named Asset.java
    public class Asset {
           ^
    Periodical.java:14: error: package Asset does not exist
    import Asset.Account;
                ^
    ./Account.java:14: error: package Periodical does not exist
    import Periodical.Asset;
                     ^
    Periodical.java:19: error: constructor Asset in class Asset cannot be applied to given types;
    	public Periodical(String aInitId, String aInitName) {
    	                                                    ^
      required: String,String,String
      found: no arguments
      reason: actual and formal argument lists differ in length
    ./Account.java:27: error: incompatible types
    		return 0;
    		       ^
      required: String
      found:    int
    5 errors

  4. #4
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Java won't compile

    Also at www.java-forums.org

Similar Threads

  1. Replies: 8
    Last Post: February 12th, 2013, 05:45 AM
  2. Code won't compile
    By JavaChallenged in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 12th, 2012, 08:18 PM
  3. file won't compile
    By bclark in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 8th, 2011, 12:13 AM
  4. [SOLVED] JMS Example + netbeans = won't compile
    By DJB79 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: June 27th, 2011, 10:40 PM
  5. *why won't this compile?*
    By dcshoecousa in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 2nd, 2010, 07:18 PM